After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 658555 - Problem with _tmp*_ variables
Problem with _tmp*_ variables
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator
0.13.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2011-09-08 13:21 UTC by Sébastien Wilmet
Modified: 2011-09-08 15:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtksourceview-2.0: Fix SourceCompletionContext.get_iter bindings (1.72 KB, patch)
2011-09-08 15:25 UTC, Luca Bruno
none Details | Review

Description Sébastien Wilmet 2011-09-08 13:21:03 UTC
Here is a sample of generated code with Vala 0.12.1 (it's OK):

static gboolean completion_provider_real_match (GtkSourceCompletionProvider* base, GtkSourceCompletionContext* context) {
        /* ... */

        GtkTextIter _tmp0_ = {0};
        GtkTextIter iter;
        GtkTextBuffer* _tmp1_ = NULL;
        GtkTextBuffer* _tmp2_;
        GtkTextBuffer* buf;

        /* ... */

        iter = _tmp0_;
        gtk_source_completion_context_get_iter (context, &iter);
        _tmp1_ = gtk_text_iter_get_buffer (&iter);

        /* ... */
}


And here is the same sample but generated with Vala 0.13.4:

static gboolean completion_provider_real_match (GtkSourceCompletionProvider* base, GtkSourceCompletionContext* context) {
        /* ... */
        
        GtkTextIter _tmp0_ = {0};
        GtkTextIter iter;
        GtkSourceCompletionContext* _tmp1_;
        GtkTextIter _tmp2_;
        GtkTextBuffer* _tmp3_ = NULL;
        
        /* ... */
        
        iter = _tmp0_;
        _tmp1_ = context;
        _tmp2_ = iter;
        gtk_source_completion_context_get_iter (_tmp1_, &_tmp2_);
        _tmp3_ = gtk_text_iter_get_buffer (&iter);
        
        /* ... */
}

There is a segfault with this code. To get the iter, Vala 0.13 assign the value to _tmp2_, but there is no "iter = _tmp2_;" afterwards. So when the next line try to get the value of "iter", there is a problem.

I didn't try to write a minimal Vala code where this bug happens, I hope that the above samples are sufficient.
Comment 1 Luca Bruno 2011-09-08 15:25:00 UTC
Created attachment 196005 [details] [review]
gtksourceview-2.0: Fix SourceCompletionContext.get_iter bindings

Fixes bug 658555.

As there's no minimal Vala code, can you please test the patch?
Comment 2 Sébastien Wilmet 2011-09-08 15:52:11 UTC
(In reply to comment #1)
> As there's no minimal Vala code, can you please test the patch?

Yes, it works! Thank you :)
Comment 3 Luca Bruno 2011-09-08 15:58:59 UTC
commit 7e3de74d8f98840d9a4bfbd9eeee31bc6e0b0dd6
Author: Luca Bruno <lucabru@src.gnome.org>
Date:   Thu Sep 8 17:23:33 2011 +0200

    gtksourceview-2.0: Fix SourceCompletionContext.get_iter bindings
    
    Fixes bug 658555.

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.