Closed Bug 1873140 Opened 6 months ago Closed 5 months ago

Avoid using invalid enum values during EnumSet iteration

Categories

(Core :: MFBT, defect, P2)

defect

Tracking

()

RESOLVED FIXED
124 Branch
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.

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

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

Attachment

General

Created:
Updated:
Size: