Closed Bug 1778767 Opened 5 months ago Closed 5 months ago

UBSan reports undefined behavior from glib's `g_clear_pointer`

Categories

(Core :: Graphics, defect, P2)

All
Linux
defect

Tracking

()

RESOLVED FIXED
104 Branch
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: nobody → jimb
Status: NEW → ASSIGNED

The deeper mystery is: why am I apparently the only one who's noticed this?

Hi, Martin - could you review this patch?

Flags: needinfo?(stransky)
Flags: needinfo?(stransky)

(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
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
Regressions: 1779364

Backed out from central for causing bug 1779364 and new desktop nightlies incoming: https://hg.mozilla.org/mozilla-central/rev/04b02c492dab34ec35205f2338b27dc9469969fc

Status: RESOLVED → REOPENED
Flags: needinfo?(jimb)
Resolution: FIXED → ---
Target Milestone: 104 Branch → ---

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

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.

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
Status: REOPENED → RESOLVED
Closed: 5 months ago5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
You need to log in before you can comment on or make changes to this bug.