Skip to content

Let the crash watchdog write to FTL.log through a copy of its path - #3354

Merged
DL6ER merged 1 commit into
pi-hole:release/v6.9.1from
010011110:v6.9-crash-watchdog-log-path
Nov 22, 2026
Merged

DL6ER merged 1 commit into
pi-hole:release/v6.9.1from
010011110:v6.9-crash-watchdog-log-path

Conversation

@010011110

Copy link
Copy Markdown
Contributor

What does this implement/fix?

for a v6.9.x, this is against master because development does not have the bug: its logger keeps its own file descriptor and cleanup() no longer frees the path

log_ftl_raw() opens config.files.log.ftl.v.s, but cleanup() frees that string when FTL.log is not at the default path (files.log.ftl in pihole.toml or FTLCONF_files_log_ftl) and leaves the pointer set. the crash watchdog writes its "FTL did not shut down after the crash" line after cleanup(), in exactly the case it exists for (exit() hanging after a crash), so it opened FTL.log through freed memory. the line could get lost or, in theory, go to another file. start_crash_watchdog() now copies the path into a static buffer that log_ftl_raw() uses, the path does not change while FTL runs

no test, it needs a crash whose shutdown hangs with FTL.log at a non-default path, and the existing crash-thread test runs in CLI mode where log_ftl_raw() does nothing

How to test the change during review

read the diff, the watchdog line is written through the copy taken in start_crash_watchdog(), nothing reads config.files.log.ftl after cleanup() anymore

Additional information

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)
  6. My change does not modify src/dnsmasq/. That tree is a verbatim copy of upstream dnsmasq and we do not carry anything in it that deviates from upstream. Fixes have to go through the dnsmasq-discuss mailing list first, we merge them once they are in dnsmasq master.

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repository's development branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@010011110
010011110 requested a review from a team as a code owner November 12, 2026 09:08

@DL6ER DL6ER left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATH_MAX needs #include <limits.h> in log.c. musl provides it through another header, glibc does not, so the CodeQL build fails:

src/log.c:41:30: error: 'PATH_MAX' undeclared here (not in a function)

@DL6ER
DL6ER changed the base branch from master to release/v6.9.1 November 13, 2026 07:11
`log_ftl_raw()` opened `config.files.log.ftl.v.s`, but `cleanup()` frees
that string when FTL.log is not at the default path (set in pihole.toml
or through `FTLCONF_files_log_ftl`). The crash watchdog writes its line
after `cleanup()`, when `exit()` hangs, so it read freed memory, and the
one line explaining the forced exit could get lost or, in theory, go to
another file. `start_crash_watchdog()` now copies the path into a static
buffer, which `log_ftl_raw()` uses. The path does not change while FTL
runs.

Signed-off-by: 010011110 <duckenheim@posteo.de>
@010011110
010011110 force-pushed the v6.9-crash-watchdog-log-path branch from bf4cf33 to f06fb05 Compare November 18, 2026 13:04
@010011110

Copy link
Copy Markdown
Contributor Author

thanks, added the limits.h include to log.c, a glibc build of it passes now

@DL6ER
DL6ER merged commit 15b4531 into pi-hole:release/v6.9.1 Nov 22, 2026
11 checks passed
@DL6ER DL6ER mentioned this pull request Nov 22, 2026
5 of 9 tasks
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