Local sccache builds can reuse an object file compiled in another checkout with different headers
Categories
(Firefox Build System :: General, defect)
Tracking
(firefox161 fixed)
| Tracking | Status | |
|---|---|---|
| firefox161 | --- | fixed |
People
(Reporter: Logan, Assigned: Logan)
References
(Blocks 1 open bug)
Details
Attachments
(1 external file)
Since bug 2031965, configure sets SCCACHE_BASEDIRS to the objdir and srcdir by default. Local builds use the disk cache, where sccache 0.18 enables preprocessor cache mode, and those two together hit https://github.com/mozilla/sccache/issues/2863: the preprocessor cache key is computed with base directories stripped, but the stored manifest records absolute include paths and is validated against the first checkout's files. A second checkout can then get the first one's object even though its headers differ.
The sccache server only uses the base directories it was started with, so building two worktrees back to back with one server doesn't trigger it. It happens once the server restarts from the other worktree (the 600s idle timeout, or sccache --stop-server), which is a normal way to switch between worktrees.
Reproduced on macOS with ~/.mozbuild/sccache/sccache 0.18.0 and ~/.mozbuild/clang, client-side mode on, each compile setting SCCACHE_BASEDIRS to only its own tree:
- Two trees with an identical
main.cthat returnsoffsetof(struct S, b), and acfg.hdeclaringstruct S { int a; int b; }in tree A andstruct S { int a; int pad; int b; }in tree B. - Compile in A (starts the server), stop the server, compile in B (starts a new one).
- B's object returns 4 instead of 8; it is A's object.
To trigger it, a translation unit needs to be identical in both checkouts while a header it includes differs, and the first checkout's headers have to still be on disk unchanged. That is routine for worktrees a few commits apart, and the result is a silently wrong object rather than a build error.
Automation isn't affected: GCS/S3 storage leaves preprocessor cache mode off in sccache 0.18.
Rust ignores SCCACHE_BASEDIRS in 0.18, and with preprocessor cache mode the C/C++ keys only line up across worktrees after such a restart, so the default buys local builds very little. Proposed fix: only set the default in automation, keep the developer override, and document the SCCACHE_DIRECT=false workaround for anyone setting it by hand. The default can come back once Firefox pins an sccache with a fix (https://github.com/mozilla/sccache/pull/2868 is open).
| Assignee | ||
Comment 1•1 month ago
|
||
With basedirs set, sccache's preprocessor cache (enabled by default for
local disk caches) can hand back an object compiled in another checkout
whose headers differ, as in mozilla/sccache#2863. Automation uses remote
storage, where the preprocessor cache is off, so keep the default there.
Updated•1 month ago
|
| Assignee | ||
Comment 2•1 month ago
•
|
||
Follow-up for after this lands: once the sccache we pin in taskcluster/kinds/fetch/toolchains.yml includes a fix for https://github.com/mozilla/sccache/issues/2863 (currently https://github.com/mozilla/sccache/pull/2868, not yet merged or released), drop the moz_automation condition on default_sccache_basedirs so local builds get the cross-checkout path rewriting back, and revert the docs workaround.
Comment 4•26 days ago
|
||
| bugherder | ||
Description
•