Closed Bug 2064182 Opened 3 months ago Closed 3 months ago

Artifact builds nondeterministically drop the fake GMP plugin libraries from the test archive

Categories

(Firefox Build System :: General, defect)

defect

Tracking

(firefox156 fixed)

RESOLVED FIXED
156 Branch
Tracking Status
firefox156 --- fixed

People

(Reporter: pehrsons, Assigned: pehrsons)

References

Details

Attachments

(1 external file)

Summary

ArtifactJob.test_artifact_patterns in python/mozbuild/mozbuild/artifacts.py is a set, but its
consumers (process_tests_zip_artifact, write_tests_tar_artifact) iterate it and break on the first
matching pattern. Two entries overlap:

("bin/plugins/gmp-*/*/*", ("bin/plugins", "bin")),      # correct
("bin/plugins/*",         ("bin/plugins", "plugins")),  # also matches - trailing * matches the subtree

mozpath.match("bin/plugins/gmp-fakeopenh264/1.0/libfakeopenh264.so", "bin/plugins/*") returns True,
so which rule wins depends on set iteration order, i.e. on PYTHONHASHSEED, which is not pinned anywhere
in the build system. Measured over 60 seeds: 35/60 (~58%) produce the wrong destination.

When it loses the flip, libfake.so and libfakeopenh264.so are written to dist/plugins/ instead of
dist/bin/. test_archive.py packages GMP plugins from dist/bin only (GMP_TEST_PLUGIN_DIRS,
test_archive.py:212), so the libraries are silently absent from the test archive - while
manifest.json / fakeopenh264.info are still present, because those come from the source tree via
FINAL_TARGET. Gecko therefore discovers the plugin and advertises H264, then the GMP child process
cannot load the library:

Hit MOZ_CRASH(Plugin file does not exist) at dom/media/gmp/GMPChild.cpp:301
PROCESS-CRASH | MOZ_CRASH(Plugin file does not exist) [@ mozilla::gmp::GMPChild::GetUTF8LibPath]

This is latent, not a recent regression - it predates the 2020 black reformat. The last content change
to the set was bug 2025276 (2026-05-07).

Impact

Artifact builds only, so in practice wpt-sync try pushes and local mach artifact builds. Never
autoland/central, never a try push with a real build. A developer running ./mach wpt on an artifact
build gets H264 crashes roughly three times in five, depending on when they last ran
mach artifact install.

Steps to reproduce

  1. Do a linux64 artifact build (ac_add_options --enable-artifact-builds).
  2. tar tf <objdir>/dist/target.common.tests.tar.zst | grep gmp-fake
  3. About 58% of the time libfake.so / libfakeopenh264.so are missing. manifest.json and
    fakeopenh264.info are present either way.
  4. Run any H264 wpt, e.g. /webrtc/simulcast/h264.https.html - it crashes.

Evidence

Two wpt-sync try pushes, same task label test-linux2404-64/debug-web-platform-tests-webrtc, same build
config (USE_ARTIFACT=1, same mozconfig):

Note the failing build did read the .so out of the upstream archive - it just wrote it to the wrong
destination. This is not an upstream-artifact problem.

Frequency, over the last 150 wpt-sync try pushes. Only 9 scheduled linux web-platform-tests-webrtc
jobs at all, which is why this stayed hidden:

08-08 08:58 63073ee2e162 build=ARTIFACT  gmp-crash=YES
08-08 11:26 3042cc6020b5 build=full      gmp-crash=no
08-10 08:13 cdafd1c51092 build=ARTIFACT  gmp-crash=YES
08-10 11:18 9c0b57352b6b build=full      gmp-crash=no
08-12 07:38 619f12d38a24 build=ARTIFACT  gmp-crash=no
08-12 11:29 ace61220b88b build=full      gmp-crash=no
08-14 08:53 a308a879bc00 build=ARTIFACT  gmp-crash=YES
08-14 13:33 522d4cb581f1 build=ARTIFACT  gmp-crash=YES
08-14 16:42 1092520c9cf1 build=full      gmp-crash=no

4 of 5 artifact pushes crashed, 0 of 4 full builds did.

Fix

Change both test_artifact_patterns definitions (ArtifactJob at artifacts.py:153, and
WinArtifactJob's override at :855) from set to tuple. The specific gmp-* pattern is already
written above the general one, so preserving source order is the entire fix. Plus a
TestTestArtifactPatterns regression test, since the failure mode is a wrong destination rather than an
error.

Verified: ./mach python-test python/mozbuild/mozbuild/test/test_artifacts.py gives 15 passed,
./mach format gives 0 problems, and the destination is now stable across PYTHONHASHSEED 0-7.

Landing this only fixes future builds. Anyone with a poisoned ~/.mozbuild/package-frontend cache or an
existing objdir needs a fresh mach artifact install to pick up the relocated .so.

test_artifact_patterns was a set, but its consumers iterate it and break on the
first matching pattern, and two of its entries overlap: mozpath.match() treats
the trailing * in "bin/plugins/" as matching a whole subtree, so it also
matches the gmp plugin paths that "bin/plugins/gmp-
//" is meant to claim.
Which one won therefore depended on set iteration order, i.e. on PYTHONHASHSEED,
which nothing in the build system pins. Roughly 58% of seeds picked the wrong
one.

When that happened, libfake.so and libfakeopenh264.so landed in dist/plugins
instead of dist/bin. test_archive.py only packages GMP plugins from dist/bin, so
the libraries went missing from the test archive while manifest.json and
fakeopenh264.info stayed, those being installed from the source tree. Gecko then
discovered the plugin and advertised H264, and the GMP child process crashed with
MOZ_CRASH(Plugin file does not exist) as soon as anything tried to use it.

Keeping the patterns in source order fixes it, since the specific gmp-* pattern
is already written above the general one.

Assignee: nobody → apehrson
Status: NEW → ASSIGNED
Pushed by pehrsons@gmail.com: https://github.com/mozilla-firefox/firefox/commit/e1685d244084 https://hg.mozilla.org/integration/autoland/rev/260e9343ddf6 Make test_artifact_patterns an ordered sequence. r=firefox-build-system-reviewers,sergesanspaille
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 156 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: