log: Fix UB with bench on genesis block #15283
pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:ub_genesis_bench changing 1 files +3 −2-
instagibbs commented at 1:06 pm on January 29, 2019: memberDuring the loading of the genesis block, the bench print lines in ConnectTip divide by zero due to early return in ConnectBlock.
-
Fix UB with bench on genesis block ec30a79f1c
-
fanquake added the label Validation on Jan 29, 2019
-
in src/validation.cpp:2448 in ec30a79f1c
2444@@ -2445,6 +2445,7 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp 2445 return error("%s: ConnectBlock %s failed, %s", __func__, pindexNew->GetBlockHash().ToString(), FormatStateMessage(state)); 2446 } 2447 nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2; 2448+ assert(nBlocksTotal > 0);
promag commented at 2:56 pm on January 29, 2019:I’d avoid this, I think it is noise as there is already a “divide by nBlocksTotal” which implies this assertion.
instagibbs commented at 3:34 pm on January 29, 2019:Not a fan of silently committing UB.
promag commented at 4:26 pm on January 29, 2019:There are 11 occurrences of/ nBlocksTotal
.DrahtBot commented at 3:45 pm on January 29, 2019: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #17037 (Testschains: Many regtests with different genesis and default datadir by jtimon)
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.
MarcoFalke renamed this:
Fix UB with bench on genesis block
log: Fix UB with bench on genesis block
on Jan 29, 2019MarcoFalke added the label Utils/log/libs on Jan 29, 2019MarcoFalke commented at 5:19 pm on January 29, 2019: memberACKpracticalswift commented at 10:34 am on January 30, 2019: contributorThis is already fixed in #14239 which was submitted back in September and is scheduled for 0.18.0 :-) @promag @MarcoFalke @instagibbs Would you mind reviewing #14239?instagibbs commented at 10:38 am on January 30, 2019: member@practicalswift sureMarcoFalke added this to the milestone 0.18.0 on Jan 30, 2019practicalswift commented at 8:23 am on January 31, 2019: contributorClose in favour of #14239?instagibbs commented at 12:22 pm on January 31, 2019: memberSGTM. Closing.instagibbs closed this on Jan 31, 2019
practicalswift commented at 12:39 pm on January 31, 2019: contributorinstagibbs commented at 7:24 pm on February 20, 2020: member@practicalswift you ended up closing that PR ;P d’ohpracticalswift commented at 7:51 pm on February 20, 2020: contributor@instagibbs Please re-open this PR :)practicalswift commented at 7:51 pm on February 20, 2020: contributorACK ec30a79f1c430cc7fbda37e5d747b0b31b262fa5instagibbs reopened this on Feb 20, 2020
jonatack commented at 8:00 pm on February 20, 2020: memberConcept ACKjonatack commented at 3:07 pm on February 21, 2020: memberOk, this PR doesn’t resolve all the UBSan issues that #17208 does, only the one involving
nBlocksTotal
.As has been noted several times previously,
nBlocksTotal
appears to be used solely for bench logging purposes and it seems to me the approach in #17208 of initializing it to 1 instead of 0 is more straightforward to review and robust against regression; this comment by @gmaxwell concurs with that.practicalswift commented at 3:55 pm on February 21, 2020: contributor@jonatack Feel free to attack the remaining ones – I’d be glad to review :)sipa commented at 5:35 pm on March 17, 2020: memberutACK ec30a79f1c430cc7fbda37e5d747b0b31b262fa5MarcoFalke merged this on Mar 17, 2020MarcoFalke closed this on Mar 17, 2020
practicalswift commented at 6:41 pm on March 17, 2020: contributorsidhujag referenced this in commit ceb70cb60a on Mar 18, 2020MarkLTZ referenced this in commit 8823f65197 on Apr 7, 2020MarkLTZ referenced this in commit 0a1571d657 on Apr 7, 2020sidhujag referenced this in commit 6fe4268440 on Nov 10, 2020MarcoFalke referenced this in commit 99fcc2b477 on Nov 13, 2020sidhujag referenced this in commit 6964401ae7 on Nov 13, 2020deadalnix referenced this in commit ad59559de1 on Jan 9, 2021ftrader referenced this in commit 52c26df386 on Apr 14, 2021DrahtBot locked this on Feb 15, 2022
instagibbs promag DrahtBot MarcoFalke practicalswift laanwj jonatack sipaLabels
Validation Utils/log/libsMilestone
0.18.0
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC
More mirrored repositories can be found on mirror.b10c.me