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 737741 - g_datalist_id_get_data assertion fails for non-existant keys
g_datalist_id_get_data assertion fails for non-existant keys
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.33.x
Other All
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-10-01 19:02 UTC by Daniel Ruoso
Modified: 2014-10-02 18:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniel Ruoso 2014-10-01 19:02:35 UTC
Before glib 2.29.6, g_datalist_get_data was a macro of the form

#define   g_datalist_get_data(dl, k)            \
 (g_datalist_id_get_data ((dl), g_quark_try_string (k)))

At which point it was converted into a regular function in 1cceda4 (released in 2.29.6).

Whenever g_datalist_get_data was called with a non-existant key, g_quark_try_string would return 0 and the function would behave as expected.

In 06e3a1d7 (released in 2.33.12) the code of g_datalist_id_get_data was changed to use a lockless mechanism, however a new assertion was added that key_id should be != 0. The function previously silently returned NULL when used with key_id == 0.

The end result is that code compiled against glib < 2.29.6 but linked against glib > 2.33.12 will show an assertion fail whenever g_datalist_get_data is called with a string that doesn't have a quark.
Comment 1 Daniel Ruoso 2014-10-01 19:07:30 UTC
I believe it would be appropriate to silently return NULL in g_datalist_id_get_data if key_id == 0.