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 771463 - variable may be used uninitialized in gtk_widget_render
variable may be used uninitialized in gtk_widget_render
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.21.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-09-15 05:08 UTC by Mohammed Sadiq
Modified: 2016-09-15 09:19 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mohammed Sadiq 2016-09-15 05:08:34 UTC
When compiling gtk+ I get the following warning:

home/sadiq/jhbuild/checkout/gtk+/gtk/gtkwidget.c: In function ‘gtk_widget_render’:
/home/sadiq/jhbuild/checkout/gtk+/gtk/gtkwidget.c:17496:5: warning: ‘context’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     gdk_window_end_draw_frame (window, context);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/sadiq/jhbuild/checkout/gtk+/gtk/gtkwidget.c:17463:22: note: ‘context’ was declared here
   GdkDrawingContext *context;
                      ^~~~~~~
If gdk_window_has_native returns FALSE, context may have undefined value, which is used in gdk_window_end_draw_frame (window, context); (line 17496)
Comment 1 Emmanuele Bassi (:ebassi) 2016-09-15 09:14:58 UTC
Which compiler is this?

That's clearly a false positive. If gdk_window_has_native() returns FALSE we don't call gdk_window_begin_paint_internal(), but we still create a valid GdkDrawingContext instance. Additionally, since GDK is a separate shared library and compilation unit, any compiler cannot determine whether or not gdk_window_begin_draw_frame() may return NULL.

The only two cases in which the GdkDrawingContext variable inside gtk_widget_render() can be unset are:

 * somebody called gdk_window_begin_draw_frame() in the middle of the rendering
 * somebody called gtk_widget_set_double_buffered() in the middle of the rendering

Any other branch of gdk_window_begin_draw_frame() results in a GdkDrawingContext instance being returned.

I have a fix for the priv->double_buffered condition being flipped in the middle of the rendering.
Comment 2 Emmanuele Bassi (:ebassi) 2016-09-15 09:18:23 UTC
Pushed to master as: https://git.gnome.org/browse/gtk+/commit/?id=bb705837bc878b6028069fd7537e89975d50d2ee
Comment 3 Mohammed Sadiq 2016-09-15 09:19:37 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #1)
> Which compiler is this?

This is gcc6 on Fedora 24

relevant part from output of gcc --version:
gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)