UBSan reports undefined behavior from glib's `g_clear_pointer`
Categories
(Core :: Graphics, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox104 | --- | fixed |
People
(Reporter: jimb, Assigned: jimb, NeedInfo)
References
Details
Attachments
(1 file)
UBSan complains about conversions between function pointer types in the Wayland code. The conversions seem unlikely to have any significance in the real world, but it's impossible to run under Wayland with UBSan turned on without fixing them.
Assignee | ||
Comment 1•2 years ago
|
||
Updated•2 years ago
|
Assignee | ||
Comment 2•2 years ago
|
||
The deeper mystery is: why am I apparently the only one who's noticed this?
Assignee | ||
Comment 3•2 years ago
|
||
Hi, Martin - could you review this patch?
Updated•2 years ago
|
Assignee | ||
Comment 5•2 years ago
|
||
(Bug 1778564 does have some useful notes, though.)
Pushed by jblandy@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cc1377cd7adb Define MozClearPointer, a type-safe replacement for g_clear_pointer. r=stransky,jgilbert
Comment 7•2 years ago
|
||
bugherder |
Comment 8•2 years ago
•
|
||
Backed out from central for causing bug 1779364 and new desktop nightlies incoming: https://hg.mozilla.org/mozilla-central/rev/04b02c492dab34ec35205f2338b27dc9469969fc
Comment 9•2 years ago
•
|
||
One of the g_clear_pointer
calls wasn't replaced with MozClearPointer
, but with wl_callback_destroy
directly, removing the null check and allowing the function to be called with a null pointer.
https://hg.mozilla.org/mozilla-central/rev/cc1377cd7adb#l3.31
Comment 10•2 years ago
•
|
||
As an alternative, what about setting GLIB_VERSION_MAX_ALLOWED
to at least GLIB_VERSION_2_58
? It seems that makes the macro safe, as it no longer casts the function pointer.
PS: Never mind, this doesn't apply to C++ unless GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68
.
Comment 11•2 years ago
|
||
Pushed by jblandy@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/56c92687fce0 Define MozClearPointer, a type-safe replacement for g_clear_pointer. r=stransky,jgilbert
Comment 12•2 years ago
|
||
bugherder |
Description
•