Bitcoin Forum
May 07, 2024, 09:31:34 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: assert(...) with side effects  (Read 511 times)
bytemaster (OP)
Hero Member
*****
Offline Offline

Activity: 770
Merit: 566

fractally


View Profile WWW
December 02, 2013, 06:09:14 PM
 #1

In main.cpp the following line within ConnectBlock has side effects which would be skipped if -DNDEBUG were to be defined. 

Code:
assert(view.SetBestBlock(pindex->GetBlockHash())); 

Seems to me the code should be

Code:
bool success = view.SetBestBlock(pindex->GetBlockHash());
assert(success);


https://fractally.com - the next generation of decentralized autonomous organizations (DAOs).
Once a transaction has 6 confirmations, it is extremely unlikely that an attacker without at least 50% of the network's computation power would be able to reverse it.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4158
Merit: 8411



View Profile WWW
December 02, 2013, 07:18:42 PM
 #2

In main.cpp the following line within ConnectBlock has side effects which would be skipped if -DNDEBUG were to be defined.  
It should be, indeed, but we don't support compiling without asserts. This is a known wart. There are a couple of other similar places that ought to be fixed. I might as well go fix it.
Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1129


View Profile
December 02, 2013, 09:39:49 PM
 #3

It's probably better to just define a custom CHECK macro that is always active. It's better to crash the node in production than to enter an undefined state.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!