Closed Bug 1614375 Opened 5 years ago Closed 5 years ago

ubsan pointer-overflow errors with clang 10

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(firefox78 fixed)

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: away, Assigned: away)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

There are various instances of this error showing up in try pushes, but the most prevalent one (which makes pretty much every linux asan test orange) is:

xmlparse.c:1942:24: runtime error: applying zero offset to null pointer

https://searchfox.org/mozilla-central/rev/a1592902acabf9bded973067133baaac1457f3d3/parser/expat/lib/xmlparse.c#1942

The amount of pointer-overflow diagnostics has increased considerably in LLVM 10: https://github.com/llvm/llvm-project/commit/536b0ee40ab97f2878dc124a321cf9108ee3d233

Blocks: clang-10

Slightly tangentially, the error mentioned in comment 0 is specified to be UB in some versions of C++, but C++17 specifically relaxed things in this regard: "If the value 0 is added to or subtracted from a null pointer value, the result is a null pointer value." C++17 [expr.add]p7.

But xmlparse.c is obviously not C++, and neither C11 nor C18 seem to include the language C++17 has to make clear that adding zero to a null pointer results in a null pointer.

Yeah, the commit message from clang says:

To make things more fun, in C (6.5.6p8), applying *any* offset to null pointer
is undefined, although Clang front-end pessimizes the code by not lowering
that info, so this UB is "harmless".
Assignee: nobody → dmajor
Status: NEW → ASSIGNED
Pushed by dmajor@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aa44cf2c1455 UBSan pointer-overflow suppressions for clang-10 r=tsmith
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla78
Pushed by dmajor@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8311d3bf80c0 bustage fix, add a couple more suppressions for straggler failures
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: