Skip to content

Write the emergency dump somewhere it can actually land#13

Open
xroche wants to merge 1 commit into
masterfrom
emergency-dump-path
Open

Write the emergency dump somewhere it can actually land#13
xroche wants to merge 1 commit into
masterfrom
emergency-dump-path

Conversation

@xroche

@xroche xroche commented Jul 17, 2026

Copy link
Copy Markdown
Owner

emergencyDump() passed Environment.getExternalStorageState() into new File(). That returns the status string, "mounted", so the dump aimed at the relative path mounted/HTTrack/error.txt, resolved against the process working directory of /, where FileWriter threw straight into an empty catch. It has never written a file, on any release. The catch now logs, since the silence is what hid it for nine years.

Being static, it had no Context to ask for a directory, which is plausibly how it drifted there in the first place. It now takes the Runner's parent activity and writes into our own external directory, falling back to the internal one. A crash path should not depend on a permission or on a volume being mounted, and this one no longer does.

The JNI glue had the same hole from the other side: assertion failures fell back to a hardcoded /mnt/sdcard/Download/HTTrack/error.txt, a storage layout gone since KitKat, whose fopen has failed quietly ever since. Once initRootPath() has run, emergencyLog already points into the mirror root; before it, there is nowhere we may legally write, and logcat carries the assertion either way. MKDIR_MODE went with it, having had no users.

Demonstrated rather than argued, since the failure is invisible by construction:

old target      : mounted/HTTrack/error.txt
  isAbsolute    : false
  resolves to   : <cwd>/mounted/HTTrack/error.txt
  FileWriter    : throws FileNotFoundException -> swallowed by the empty catch

No tracker issue matches these symptoms in either repo, so there is nothing to close. Independent of the storage PRs, and compatible with either root. The new path needs a device to confirm end to end, which is not available yet.

emergencyDump() passed Environment.getExternalStorageState() to new File().
That returns the status string, "mounted", so the dump went to the relative
path mounted/HTTrack/error.txt, resolved against the process working
directory of /, where FileWriter threw straight into an empty catch. It has
never written a file, on any release. The catch now logs, since silence is
what hid this.

Being static, it had no Context to ask for a directory, which is likely how
it drifted; it takes the Runner's parent activity instead, and writes into
our own external directory, falling back to the internal one. A crash path
must not depend on a permission or on a volume being mounted, and neither
does that.

The JNI glue had the same hole: assertion failures fell back to a hardcoded
/mnt/sdcard/Download/HTTrack/error.txt, a layout gone since KitKat, whose
fopen has been failing quietly ever since. Once initRootPath() has run,
emergencyLog already points into the mirror root; before it, there is nowhere
we may write, and logcat has the assertion either way. MKDIR_MODE went with
it, having no users.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
fclose(dumpFile);
/* Nothing is writable before initRootPath(); logcat above carries it either way. */
if (emergencyLog != NULL) {
FILE *const dumpFile = fopen(emergencyLog, "wb");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants