init: avoid pointing to a disabled debug log on failure #37034

Open
l0rinc wants to merge 2 commits from l0rinc/no-log-file-errors into master AGit
l0rinc commented 2026-12-01 18:29:37 +00:00 (Migrated from github.com)

Problem: When startup fails under -daemonwait, the daemon points to the debug log for details.
With -nodebuglogfile, that hint reads check for details, and fatal errors also include an empty log reference before the cause.

Fix: When file logging is disabled, suggest running in the foreground for startup details and report the fatal error directly.

Reproduce the daemon message on Unix
build/bin/bitcoind -regtest -datadir="$(mktemp -d)" -daemonwait -nodebuglogfile -pid=missing/bitcoind.pid

With the fix, this prints Error during initialization - run in the foreground for details.
Without -daemonwait, the error names the PID file the node couldn't create.

**Problem:** When startup fails under `-daemonwait`, the daemon points to the debug log for details. With `-nodebuglogfile`, that hint reads `check for details`, and fatal errors also include an empty log reference before the cause. **Fix:** When file logging is disabled, suggest running in the foreground for startup details and report the fatal error directly. <details> <summary>Reproduce the daemon message on Unix</summary> ```bash build/bin/bitcoind -regtest -datadir="$(mktemp -d)" -daemonwait -nodebuglogfile -pid=missing/bitcoind.pid ``` With the fix, this prints `Error during initialization - run in the foreground for details`. Without `-daemonwait`, the error names the PID file the node couldn't create. </details>
DrahtBot commented 2026-12-01 18:29:48 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK jeanpablojp

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35911 (Warn on and add missing [[noreturn]] by fanquake)
  • #35355 (Use atomics for determining whether trace logging is enabled by ajtowns)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/37034 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/37034.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/37034#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/37034#pullrequestreview-6169542001) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#35911](https://github.com/bitcoin/bitcoin/pull/35911) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35911.svg"></sub> (Warn on and add missing `[[noreturn]]` by fanquake) * [#35355](https://github.com/bitcoin/bitcoin/pull/35355) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35355.svg"></sub> (Use atomics for determining whether trace logging is enabled by ajtowns) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

No findings were published from this review.

Review coverage was incomplete.


Reviewed: fbac7f04147a · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:312ddb2095238aa2ca395a9cc39b05ab5a38a7177afbdb0d69098df9c3e0bef9:9a7f127b15c6116c267953d38288a9f17ec7c7bcd3a975fb71a2db8bfd974dbf --> <!-- ralph-base:5c4e8374074f1c247e88c4fc12fc5b8858e6ff6f --> <!-- ralph-head:fbac7f04147aece0f364c8499503bb6366f24305 --> <!-- ralph-case:5323312650ddba7d97dd33054bfbcca2dfa73ea986b31a425c5e067b41dcaa85 --> No findings were published from this review. Review coverage was incomplete. <!-- Review tier: standard --> --- Reviewed: [`fbac7f04147a`](<https://git.fish.foo/bitcoin/bitcoin/commit/fbac7f04147aece0f364c8499503bb6366f24305>) · [Review report](<https://review.fish.foo/report/37034-fbac7f04147aece0f364c8499503bb6366f24305-3407-1.html>) · [Previous reports](<https://review.fish.foo/traces/37034/>) [permalink](<https://review.fish.foo/report/37034-fbac7f04147aece0f364c8499503bb6366f24305-3407-1.html>)
jeanpablojp (Migrated from github.com) reviewed 2026-12-03 12:12:28 +00:00
jeanpablojp (Migrated from github.com) left a comment

tACK fbac7f0414

tACK fbac7f04147aece0f364c8499503bb6366f24305
jeanpablojp (Migrated from github.com) commented 2026-12-03 12:12:28 +00:00

With file logging on, the new test's PID failure says check debug.log for details, but the child fails before StartLogging, so the error never reaches the log file, with or without this PR.

                    const auto hint{LogInstance().m_print_to_file ? strprintf("check %s or run in the foreground", fs::PathToString(LogInstance().m_file_path.filename())) : "run in the foreground"};
With file logging on, the new test's PID failure says `check debug.log for details`, but the child fails before `StartLogging`, so the error never reaches the log file, with or without this PR. ```suggestion const auto hint{LogInstance().m_print_to_file ? strprintf("check %s or run in the foreground", fs::PathToString(LogInstance().m_file_path.filename())) : "run in the foreground"}; ```
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!37034
No description provided.