-
Notifications
You must be signed in to change notification settings - Fork 1.2k
backport: Merge bitcoin# 28035, 26957 #7258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -151,7 +151,7 @@ def run_test(self): | |||||||||||||||||||
|
|
||||||||||||||||||||
| def governance_tip_updated(node): | ||||||||||||||||||||
| with open(node.debug_log_path, encoding='utf-8') as dl: | ||||||||||||||||||||
| seek_pos = node.debug_log_bytes() - 100 * 1024 # read the last 100 KiB only | ||||||||||||||||||||
| seek_pos = node.debug_log_size(mode="rb") - 100 * 1024 # read the last 100 KiB only | ||||||||||||||||||||
| dl.seek(seek_pos if seek_pos > 0 else 0) | ||||||||||||||||||||
| debug_log_part = dl.read() | ||||||||||||||||||||
|
Comment on lines
153
to
156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking: Governance log polling seeks to a byte offset on a UTF-8 text stream
💡 Suggested change
Suggested change
source: ['codex-general'] 🤖 Fix this with AI agents |
||||||||||||||||||||
| return expected_msg in debug_log_part | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: dashpay/dash
Length of output: 1772
🌐 Web query:
Dash dash feature_governance_cl.py debug_log_path UTF-8 text mode seek💡 Result:
In Dash Core’s functional test framework,
debug_log_pathis the per-node logfile at:chain_path / "debug.log"(i.e.,<datadir>/<chain>/debug.log). In code it’s exposed as thedebug_log_pathproperty onTestNode. [1]The problem with UTF-8 + text mode + seek is in how the test framework tracks “where it last read up to” in
debug.log:debug_log_bytes()opens the log in text mode (open(..., encoding="utf-8")), doesseek(0, 2)and returnstell(). [1]assert_debug_log()later re-opens the file in text mode and doesdl.seek(prev_size)whereprev_sizecame from that earliertell(). [1]On some platforms (notably Windows), text-mode seeks are not byte-offset seeks (they use an opaque cookie tied to newline/decoder state), so using these offsets as if they were stable byte positions can lead to “text mode seek” errors or incorrect positioning.
Fix (robust approach): do offset tracking in binary mode, decode after reading, e.g.:
Path.stat().st_sizeoropen(..., "rb")/tell()open(..., "rb"),seek(prev_size),read(), then.decode("utf-8", errors="replace")This avoids text-mode
seek()semantics entirely while still letting you search log text for expected messages. [1]Source(s)
[1] Dash Core
test_node.pyimplementation ofdebug_log_path,debug_log_bytes(), andassert_debug_log(). (github.com)Citations:
Avoid mixing binary byte offsets with text-mode
seek().Line 154 computes a byte offset using
debug_log_size(mode="rb"), but lines 153–155 open and seek the file in text mode withencoding='utf-8'. This mismatch causes invalid seek positions for UTF-8 and can produce flaky reads, especially on Windows where text-mode seeks use opaque decoder state.Open the file in binary mode and decode explicitly after reading:
Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents