You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prevent SQLite handle exhaustion from aborting processing runs - #2431
During a Full File System extraction, iLEAPP stopped at powerlogGenerativeAssetLoad with OSError: [Errno 24] Too many open files. The entire processing run failed to complete, rather than only losing one PowerLog artifact. Opening a SQLite database failed first, then logging the error and the outer exception both failed because they needed another file descriptor.
One failed run is documented in the retained log. The examiner reports that an earlier attempt stopped at the same point; that earlier output was deleted before diagnosis.
get_sqlite_db_records returns a cursor without explicitly closing its connection. A synthetic reproduction using the installed helper increased open descriptors from 4 to 104 after 100 reads; explicit garbage collection released them. The SQLite connection context manager in open_sqlite_db_readonly does not close the returned connection.
Change
Stream query results through a generator with cursor and connection cleanup in finally, including query/attach errors and explicit early closure.
Close the PowerLog table-name iterator explicitly when returning a matching table early.
Remember failed PowerLog gzip decompressions for the session and remove their partial temporary files. The same truncated archive was previously attempted 17 times in the failed run.
Add synthetic regression tests for cleanup and damaged-archive handling.
Callers that retain the iterator and stop early must close it, or use contextlib.closing. Rows remain sqlite3.Row objects, and the reader does not materialize the full result set. The newer logging recovery already present on main (#2403) is retained, not introduced by this PR.
Validation
Focused suite on current upstream plus this patch: 78 passed, 3 Windows-specific skips; changed-files lint introduced no warnings.
Synthetic cleanup tests cover successful and empty reads, invalid queries, invalid ATTACH, explicit early close, a consumer exception with closing, a logging exception, and a missing database.
1,000 repeated reads with garbage collection disabled verify that connections are explicitly closed.
The rebuilt app processed 30 synthetic PowerLog databases, including plain and gzip inputs, preserved all 30 expected rows, logged one truncated archive once, and completed report generation without a traceback.
The locally rebuilt macOS app passed startup, empty-extraction report generation, raw-image walking, and GUI self-checks.
The examiner reran the real Full File System extraction locally. The run reached 1120/1120 scheduled artifacts and completed report generation in 22 minutes 27 seconds, with no Too many open files errors. Thirteen PowerLog exports contained 390,531 rows. powerlogGenerativeAssetLoad completed normally and reported no data found; the truncated archive was logged once and skipped.
The real-data check confirms run completion and exported counts, not an independent validation of every source record. A separate webkit_cache_records failure (AttributeError: 'str' object has no attribute 'hex') and Biome Maps intent-decoding warnings remained; those are outside this fix. The real rerun used the downloaded 2026.4.5-dev source plus this patch, including its newer upstream logging safeguard, so it was not a controlled test of only this patch against the older installed binary.
No case files, raw case logs, client identifiers, or local case paths are included. All committed fixtures are generated synthetically.
The changed artifact modules cite public research images in their sample_data, so a maintainer can generate the test fixtures from those images. Nothing is needed from you, though you are welcome to add the fixtures yourself with admin/test/scripts/make_test_data.py.
powerlog.py: cites abe_ios16, ctf2020_ios12, dexter_ios18, felix23_ios16, felix_ios17, hickman_ios13, hickman_ios14, hickman_ios15, iphone11_ios17, iphone12_ios18, iphone14plus_ios18, magnet_ios16, otto_ios17; a maintainer can generate the fixture.
Thanks for finding this and for the careful write-up. The handle leak was real and your fix for it is merged: your commit went in through #2432.
I had to adjust one thing on top. As a generator the helper no longer ran the query at the call or returned [] on failure, and a couple of artifacts depend on that (one reads description from the result, one only probes the database). #2432 keeps your cleanup and puts that behavior back. Closing this one since the work is in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fixture-neededCites a public image; a maintainer can generate the fixture
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
During a Full File System extraction, iLEAPP stopped at
powerlogGenerativeAssetLoadwithOSError: [Errno 24] Too many open files. The entire processing run failed to complete, rather than only losing one PowerLog artifact. Opening a SQLite database failed first, then logging the error and the outer exception both failed because they needed another file descriptor.One failed run is documented in the retained log. The examiner reports that an earlier attempt stopped at the same point; that earlier output was deleted before diagnosis.
get_sqlite_db_recordsreturns a cursor without explicitly closing its connection. A synthetic reproduction using the installed helper increased open descriptors from 4 to 104 after 100 reads; explicit garbage collection released them. The SQLite connection context manager inopen_sqlite_db_readonlydoes not close the returned connection.Change
finally, including query/attach errors and explicit early closure.Callers that retain the iterator and stop early must close it, or use
contextlib.closing. Rows remainsqlite3.Rowobjects, and the reader does not materialize the full result set. The newer logging recovery already present on main (#2403) is retained, not introduced by this PR.Validation
Focused suite on current upstream plus this patch: 78 passed, 3 Windows-specific skips; changed-files lint introduced no warnings.
Synthetic cleanup tests cover successful and empty reads, invalid queries, invalid ATTACH, explicit early close, a consumer exception with
closing, a logging exception, and a missing database.1,000 repeated reads with garbage collection disabled verify that connections are explicitly closed.
The rebuilt app processed 30 synthetic PowerLog databases, including plain and gzip inputs, preserved all 30 expected rows, logged one truncated archive once, and completed report generation without a traceback.
The locally rebuilt macOS app passed startup, empty-extraction report generation, raw-image walking, and GUI self-checks.
The examiner reran the real Full File System extraction locally. The run reached 1120/1120 scheduled artifacts and completed report generation in 22 minutes 27 seconds, with no
Too many open fileserrors. Thirteen PowerLog exports contained 390,531 rows.powerlogGenerativeAssetLoadcompleted normally and reported no data found; the truncated archive was logged once and skipped.The real-data check confirms run completion and exported counts, not an independent validation of every source record. A separate
webkit_cache_recordsfailure (AttributeError: 'str' object has no attribute 'hex') and Biome Maps intent-decoding warnings remained; those are outside this fix. The real rerun used the downloaded2026.4.5-devsource plus this patch, including its newer upstream logging safeguard, so it was not a controlled test of only this patch against the older installed binary.No case files, raw case logs, client identifiers, or local case paths are included. All committed fixtures are generated synthetically.