Open
Bug 1404151
Opened 7 years ago
Updated 2 years ago
fsanitize=enum (ubsan) runtime errors in tools/profiler/lul/LulDwarf.cpp
Categories
(Core :: Gecko Profiler, defect, P3)
Core
Gecko Profiler
Tracking
()
NEW
People
(Reporter: arthur, Unassigned)
References
(Blocks 1 open bug)
Details
I'm working on fixing ubsan enum errors in the codebase. In running the full Linux test suite with -fsanitize=enum, I observe the following errors:
> [task 2017-09-25T00:46:49.602Z] 00:46:49 INFO - TEST-START | GeckoProfiler.FeaturesAndParams
> [task 2017-09-25T00:46:49.603Z] 00:46:49 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1399:38: runtime error: load of value 4294967195, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:46:49.603Z] 00:46:49 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1404:39: runtime error: load of value 4294967195, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:46:49.603Z] 00:46:49 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1411:40: runtime error: load of value 4294967195, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:46:49.604Z] 00:46:49 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1612:52: runtime error: load of value 4294967195, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:46:53.619Z] 00:46:53 INFO - TEST-PASS | GeckoProfiler.FeaturesAndParams | test completed (time: 4047ms)
and
> [task 2017-09-25T00:47:00.109Z] 00:47:00 INFO - TEST-START | LulDwarfEHFrame.SimpleFDE
> [task 2017-09-25T00:47:00.109Z] 00:47:00 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1381:38: runtime error: load of value 4294967226, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:47:00.109Z] 00:47:00 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1497:35: runtime error: load of value 4294967226, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:47:00.109Z] 00:47:00 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1504:36: runtime error: load of value 4294967226, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:47:00.109Z] 00:47:00 INFO - /builds/worker/workspace/build/src/tools/profiler/lul/LulDwarf.cpp:1620:58: runtime error: load of value 4294967226, which is not a valid value for type 'DwarfPointerEncoding'
> [task 2017-09-25T00:47:00.109Z] 00:47:00 INFO - TEST-PASS | LulDwarfEHFrame.SimpleFDE | test completed (time: 0ms)
So I looked at the code near tools/profiler/lul/LulDwarf.cpp:1399 and here it is:
> case DW_Z_has_personality_routine:
> // The CIE's augmentation data holds the personality routine
> // pointer's encoding, followed by the pointer itself.
> cie->has_z_personality = true;
> // Fetch the personality routine pointer's encoding from the
> // augmentation data.
> if (data >= data_end) return ReportIncomplete(cie);
> cie->personality_encoding = DwarfPointerEncoding(*data++);
> if (!reader_->ValidEncoding(cie->personality_encoding)) {
> reporter_->InvalidPointerEncoding(cie->offset,
> cie->personality_encoding);
> return false;
> }
The problem is, `data` is defined as a (const signed char *). In the first four errors, `*data` is equal to 0xFF (DW_EH_PE_omit), and it is cast to a DwarfPointerEncoding, so we get int(-1) instead of 0xFF.
In the last four errors, for some reason `*data` is equal to 0xBA. That doesn't correspond to any allowed enum value, and I haven't tracked down why yet. But probably we should be checking for a correct value *before* casting to a DwarfPointerEncoding type.
In any case, I noticed there is a newer version of the same code in the crashreporter:
https://dxr.mozilla.org/mozilla-central/rev/76a26ef7c493311c170ae83eb0c1d6592a21396d/toolkit/crashreporter/google-breakpad/src/common/dwarf/dwarf2reader.cc#2348
and in that version, `data` is a (const uint8_t*) instead. So that would fix the first four runtime errors ast least.
So I can think of three options:
1. Refactor to use the crashreporter copy of dwarf2reader.cc in crashreporter
2. Update LulDwarf.cpp to the latest breakpad code
3. Apply patch https://chromium.googlesource.com/breakpad/breakpad/+/bc44efdc274aaf5b3b575d66f7e245754c0fa1e1%5E%21/ which switched from unsigned char to uint8_t.
Reporter | ||
Comment 1•7 years ago
|
||
Hi Nicholas -- any opinions as to how to proceed? Thanks.
Blocks: ubsan
Flags: needinfo?(n.nethercote)
Comment 2•7 years ago
|
||
I will defer to jseward, who is the expert on LUL.
Flags: needinfo?(n.nethercote) → needinfo?(jseward)
Priority: -- → P3
Updated•4 years ago
|
Flags: needinfo?(jseward)
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•