Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Sep 3, 2021

The format string is evaluated differently on modern compilers (clang 10 and later, as well as gcc 10 and later).

Work around the behaviour change in compilers by pinning the underlying type of the format arguments.

Can be tested by observing a failing test when running against master compiled with clang 10 or gcc 10 (or later).

@practicalswift
Copy link
Contributor

Context for other reviewers: c42f/tinyformat#82

@maflcko
Copy link
Member Author

maflcko commented Sep 6, 2021

Context for other reviewers: c42f/tinyformat#82

I think the changes here make sense even without the issue (and whether it is a bug or not).

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 6, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22831 (test, bugfix: addrman tried table corruption on restart with asmap by jonatack)

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.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK fab0b55 verified the test fails on master as expected only at line 61 (assertion fixed by the code change); the last two test additions pass as expected

2021-09-06T13:36:53.543000Z TestFramework (INFO): Check that addrman from future cannot be read
2021-09-06T13:36:55.715000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
    self.run_test()
  File "/home/jon/projects/bitcoin/bitcoin/test/functional/feature_addrman.py", line 61, in run_test
    self.start_node(0)
  File "/usr/lib/python3.9/contextlib.py", line 126, in __exit__
    next(self.gen)
  File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/test_node.py", line 400, in assert_debug_log
    self._raise_assertion_error('Expected messages "{}" does not partially match log:\n\n{}\n\n'.format(str(expected_msgs), print_log))
  File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/test_node.py", line 166, in _raise_assertion_error
    raise AssertionError(self._node_msg(msg))
AssertionError: [node 0] Expected messages "['ERROR: DeserializeDB: Deserialize or I/O error - Unsupported format of addrman database: 1. It is compatible with formats >=111, but the maximum supported by this version of Bitcoin Core is 3.', 'Recreating peers.dat']" does not partially match log:
...
 - 2021-09-06T13:36:53.840640Z [init] [util/system.h:51] [error] ERROR: DeserializeDB: Deserialize or I/O error - Unsupported format of addrman database: \x01. It is compatible with formats >=111, but the maximum supported by this version of Bitcoin Core is 3.: iostream error

self.stop_node(0)
write_addrman(peers_dat, lowest_compatible=111)
with self.nodes[0].assert_debug_log([
f'ERROR: DeserializeDB: Deserialize or I/O error - Unsupported format of addrman database: 1. It is compatible with formats >=111, but the maximum supported by this version of {self.config["environment"]["PACKAGE_NAME"]} is 3.',
Copy link
Member

Choose a reason for hiding this comment

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

nit, line length

-        f'ERROR: DeserializeDB: Deserialize or I/O error - Unsupported format of addrman database: 1. It is compatible with formats >=111, but the maximum supported by this version of {self.config["environment"]["PACKAGE_NAME"]} is 3.',
+       "ERROR: DeserializeDB: Deserialize or I/O error - Unsupported format of "
+        "addrman database: 1. It is compatible with formats >=111, but the maximum "
+        f"supported by this version of {self.config['environment']['PACKAGE_NAME']} is 3.",

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, will fix on next force push, if there is one

Copy link
Contributor

@mzumsande mzumsande left a comment

Choose a reason for hiding this comment

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

ACK fab0b55
I verified with clang 10 that this corrects the format.
facce4c looks ok but unrelated.

@maflcko
Copy link
Member Author

maflcko commented Sep 8, 2021

facce4c looks ok but unrelated.

Right. Didn't seem worth it to open a separate pull for this "trivial style" fix. I found it while working on this pull, so at least it is loosely related 😅

@fanquake fanquake merged commit 7d7d5e8 into bitcoin:master Sep 8, 2021
@maflcko maflcko deleted the 2109-testPeersDat branch September 8, 2021 07:32
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 11, 2021
fab0b55 addrman: Fix format string in deserialize error (MarcoFalke)
facce4c test: Remove useless overwrite (MarcoFalke)

Pull request description:

  The format string is evaluated differently on modern compilers (clang 10 and later, as well as gcc 10 and later).

  Work around the behaviour change in compilers by pinning the underlying type of the format arguments.

  Can be tested by observing a failing test when running against master compiled with clang 10 or gcc 10 (or later).

ACKs for top commit:
  jonatack:
    ACK fab0b55 verified the test fails on master as expected only at line 61 (assertion fixed by the code change); the last two test additions pass as expected
  mzumsande:
    ACK fab0b55

Tree-SHA512: 07462901435107f3bc79098fd7d06446bfe8fe065fffdd35adfcba8f1dd3c499575006557afe7bc74b79d690c5ef7b58e3e031e908161be5529cf237e3b30609
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 10, 2021
Also add a regression test.

Github-Pull: bitcoin#22879
Rebased-From: fab0b55
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 14, 2021
Also add a regression test.

Github-Pull: bitcoin#22879
Rebased-From: fab0b55
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants