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 727687 - segfault: gtk_entry_set_text calls strcmp with a NULL pointer
segfault: gtk_entry_set_text calls strcmp with a NULL pointer
Status: RESOLVED NOTGNOME
Product: gtk+
Classification: Platform
Component: .General
3.12.x
Other FreeBSD
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-04-05 22:40 UTC by Gustau Pérez i Querol
Modified: 2014-04-12 07:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix of -DG_DISABLE_CHECKS (954 bytes, patch)
2014-04-06 09:15 UTC, Gustau Pérez i Querol
none Details | Review

Description Gustau Pérez i Querol 2014-04-05 22:40:30 UTC
This is with gtk-3.12.0 and glib-2.40.0 compiled with debug symbols. I'm seeing that evolution segfaults when starting. 

The backtrace (attached here) shows that gtk_entry_set_text calls strcmp with the *text pointer being null. Checking the code it shouldn't happen because there's a g_return_if_fail (text != NULL).
Comment 1 Gustau Pérez i Querol 2014-04-06 09:14:32 UTC
In the API it is stated that g_return_if_fail and g_return_vail_if_fail are not checked if G_DISABLE_CHECKS is set at compile time. This happens when --enable-debug=no is explicitly set. 

It would appear this is not the expected behavior because those checks are used in gtk and may lead to segfaults within the gtk itself (the code in gtk_entry_set_text in the gtk/gtkentry.c file relies on g_return_if_fail to check if strcmp will be called with a NULL pointer or not). 

The attached simple patch (git format patch) addresses that in the configure.ac.
Comment 2 Gustau Pérez i Querol 2014-04-06 09:15:01 UTC
Created attachment 273648 [details] [review]
Fix of -DG_DISABLE_CHECKS
Comment 3 Matthias Clasen 2014-04-12 05:10:13 UTC
Calling gtk_entry_set_text with a NULL text is a bug in evolution and needs to be fixed there.
Comment 4 Gustau Pérez i Querol 2014-04-12 07:49:38 UTC
I'd say the gtk_entry_set_text routine checks if the val is NULL and if so that routine returns, thus it is expected to call it with a NULL value and if that happens gtk_entry_set_text correctly returns. 

Adding -DG_DISABLE_CHECKS makes g_return_[val_]if_fail not to be checked. That makes gtk_entry_set_text to behave different if -DG_DISABLE_CHECKS is provided or not, leading to a segfault of gtk even if gtk_entry_set_text has an explicit check of the text argument. 

Because of that I'd say even that evolution is not right calling gtk_entry_set_text with a NULL argument I'd say that gtk shouldn't segfault when text is NULL, there's already a protection to check that.