Open Bug 2095499 Opened 13 days ago Updated 2 days ago

32-bit Firefox runs out of address space at startup in the remote_settings orphaned-attachment migration (schema v3 to v4)

Categories

(Application Services :: Remote Settings, defect)

defect

Tracking

(Not tracked)

People

(Reporter: jstutte, Unassigned)

References

(Regression)

Details

(Keywords: regression)

While building a memory telemetry dashboard I noticed that main-process OOM crashes on 32-bit Windows release roughly doubled with Firefox 152. Looking at crash reports and minidumps, they appear to come from the one-shot migration that cleans up orphaned attachments in the Remote Settings database: it runs at startup and journals the whole delete in memory. Details below.


Telemetry. Release, Windows, 32-bit Firefox builds (Glean architecture = x86), clients with a main-process OOM crash (telemetry.firefox_crashes, memory.oom_allocation_size set) per 1k client-days, June to July 2026:

Version Main-process OOM Content-process OOM
151.0.2 to 151.0.4 2.4 to 3.5 about 7
152.0 to 152.0.5 5.7 to 8.0 7.3 to 8.2

The step follows the version, not the date: clients still on 151.x after 2026-06-16 did not rise. 64-bit main-process OOMs stayed flat (0.39 to 0.42 per 1k daily users). Later versions stay elevated (about 4.5 to 5 per 1k on 32-bit through September). On Socorro, 32-bit release parent-process OOM | small reports went from 1,279 (2026-06-01 to 06-09) to 13,426 (2026-06-17 to 06-26), almost all on 152.0 and 152.0.1, with crashing stacks spread over unrelated allocation sites.

Uptime. The crashes happen right after startup:

151.0.3 152.0.1
Parent OOMs under 1 hour of uptime 52% 86%
Of those, at 10 to 60 seconds 21% 51%

Thread stacks. In a sample of 12 crashes on 152.0.1 at 10 to 60 seconds of uptime, every report has a BgIOThreadPool thread in the migration; none of 11 comparable 151.0.3 reports has one. For example 6d86b42e-d6ec-44a6-ae13-d12430260618:

memjrnlClose
releaseAllSavepoints
pager_end_transaction
sqlite3PagerRollback
...
sqlite3_step
rusqlite::statement::Statement::execute_with_bound_parameters
remote_settings::schema::impl$0::upgrade_from
sql_support::open_database::do_open_database_with_flags<remote_settings::schema::RemoteSettingsConnectionInitializer, ...>
remote_settings::storage::Storage::transaction
remote_settings::storage::Storage::get_last_modified_timestamp
remote_settings::client::RemoteSettingsClient<...>::sync
suggest::store::SuggestStoreInner<...>::ingest
suggest::store::uniffi_suggest_fn_method_suggeststore_ingest

Other reports catch the same thread earlier, inside memjrnlWrite < subjournalPageIfRequired < pager_write < freePage2 < clearCellOverflow < sqlite3BtreeDelete. Sample report IDs: 6d86b42e-d6ec-44a6-ae13-d12430260618, dc11e226-0d51-408e-ba74-a1a1d0260618, 1aa4eba2-ad8a-4ab7-b2d7-120cd0260618, f7be5e7d-0cc2-4a22-bf2b-f7b6d0260618, b2fba8e2-28e1-4124-b350-621820260618, 244507f4-69f3-4741-9c05-c68e50260618.

Memory map (MemoryInfoList stream of the minidumps, 32-bit processes on 64-bit Windows, so 4 GiB of address space):

Report Version Uptime 1 MiB private allocations (mozjemalloc chunks) Committed in them Free address space
6d86b42e 152.0.1 26 s 3,095 2,825 MiB 123 MiB
b2fba8e2 152.0.1 10 s 3,056 2,940 MiB 128 MiB
4524f9f7-4c45-4b93-83b0-6968a0260701 151.0.3 13 s 588 476 MiB 221 MiB

So in 152 the parent's heap grows to almost 3 GiB of committed memory within seconds of startup. The 151.0.3 baseline also ran out of address space, but through about 800 large 2 to 5 MiB allocations, a different pattern.

Mechanism. Step 3 of upgrade_from (from bug 2029668, in Firefox 152 through the Application Services update in bug 2030657) runs one DELETE FROM attachments WHERE NOT EXISTS (SELECT 1 FROM records WHERE json_extract(records.data, '$.attachment.location') = attachments.id) inside the upgrade transaction. Bug 2029668 notes that the bug being cleaned up let these databases grow to 1 GB or more. The connection sets PRAGMA temp_store = 2, so SQLite keeps the statement journal in memory and copies each page the delete touches into it. On a large database this exhausts a 32-bit address space, the transaction rolls back, the schema version stays at 3, and the migration runs again at the next startup, so affected profiles presumably crash on every launch. On 64-bit it presumably completes, but still commits GBs at startup (not measured). The migration is unchanged on main as of 2026-11-20.

Possible fixes: delete in batches with a commit between them; run the migration with a file-backed temp store; or, since attachments are a cache, drop them all and let them be downloaded again instead of the filtered delete.


Depends on: 2096379
Depends on: 2100123
You need to log in before you can comment on or make changes to this bug.