Avoid using invalid enum values during EnumSet iteration
Categories
(Core :: MFBT, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox124 | --- | fixed |
People
(Reporter: janv, Assigned: janv)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
EnumSet iterates over all bits during value iteration and calls contains(T(mPos))
to see if the current bit is set:
https://searchfox.org/mozilla-central/rev/9c509b8feb28c1e76ad41e65bf9fd87ef672b00f/mfbt/EnumSet.h#245
This can lead to using invalid enum values internally and ASAN actually complains about it:
/builds/worker/workspace/obj-build/dist/include/mozilla/EnumSet.h:186:49: runtime error: load of value 8, which is not a valid value for type 'mozilla::dom::quota::PersistenceType'
https://treeherder.mozilla.org/logviewer?job_id=442006377&repo=try&lineNumber=40691
EnumSet iteration is not much used yet probably, otherwise this would be discovered earlier.
Assignee | ||
Comment 1•6 months ago
|
||
size_t is already correctly used in many places, only ConstIterator uses
uint32_t for position tracking. It would be better to align these data types
and use size_t everywhere.
Depends on D195373
Assignee | ||
Comment 2•6 months ago
|
||
Depends on D197774
Assignee | ||
Comment 3•6 months ago
|
||
Depends on D197781
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3efd9fe10a91 Align index data types in EnumSet implementation; r=glandium https://hg.mozilla.org/integration/autoland/rev/c20fae770bb7 Align internal methods to use UpperCamelCase in EnumSet implementation; r=glandium https://hg.mozilla.org/integration/autoland/rev/6bd4afd8cb60 Avoid using invalid enum values during EnumSet iteration; r=glandium
Comment 5•5 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3efd9fe10a91
https://hg.mozilla.org/mozilla-central/rev/c20fae770bb7
https://hg.mozilla.org/mozilla-central/rev/6bd4afd8cb60
Description
•