Closed Bug 1761040 Opened 2 years ago Closed 2 years ago

Consider renaming the thread safety macros

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: fabrice, Assigned: fabrice)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

On Gonk, we had to workaround re-definition of the CAPABILITY macro because of some unfortunate include sequence in unified builds. That looks like:

  1. #include "mfbt/ThreadSafety.h" -> CAPABILITY is defined, as well as the mozilla_ThreadSafety_h header guard.

  2. One of b2g-sysroot/include/android-base/thread_annotations.h or b2g-sysroot/include/utils/Mutex.h are included, modifiying CAPABILITY (these headers are from the android sysroot).

  3. #include "mfbt/ThreadSafety.h" appears again, but because mozilla_ThreadSafety_h is defined, CAPABILITY keeps the android sysroot value.

  4. Kaboom.

We worked around on Gonk with a crappy "let's always re-include ThreadSafety.h" (https://github.com/kaiostech/gecko-b2g/commit/94b6ac940c927061200244768f32a5e9db30f96d) but this is not great obviously, and that could happen to other platforms.

I think using a unique name for these macros would prevent such issues down the line.

Summary: Consider renaming the thread safety defines → Consider renaming the thread safety macros
Flags: needinfo?(rjesup)

ping Jesup. Can we figure out a good way out of this?

Either remove the thread safety macros to use MOZ_ prefixes, or use #pragma push_macro("CAPABILITY") like we do here or so?

Assignee: nobody → fabrice
Status: NEW → ASSIGNED

The try run is at https://treeherder.mozilla.org/jobs?repo=try&revision=d2d829d6bf390d3c46b2b3f340e2e9bca31816a3

Most of the changes have been generated by applying this script with the needed macro name as input:

#!/bin/bash

export SEARCH=$1

SED_ARG="s/${SEARCH}/MOZ_${SEARCH}/g"

rg -l " $SEARCH\(" | grep -v -E "other_licenses|third_party|security/sandbox/chromium|toolkit/components/protobuf" | xargs sed -i $SED_ARG

And a couple of manual fixup in tests afterwards.

Depends on D152575

I'm not sure why TC complains about:

Message: 'rlbox.wasm.h' file not found
Location: gfx/thebes/ThebesRLBox.h:17

since this patch doesn't touch that file and running ./mach static-analysis check --outgoing locally does not produce errors.

Attachment #9286747 - Attachment is obsolete: true
Pushed by rjesup@wgate.com:
https://hg.mozilla.org/integration/autoland/rev/a907159a482f
Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Pushed by apavel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b9d2965591b9
Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Backout by apavel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/05ab424ab12d
Backed out changeset b9d2965591b9 for landing with wrong author CLOSED TREE DONTBUILD
Pushed by abutkovits@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/10d13b6a9379
Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch
Flags: needinfo?(rjesup)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: