Computes 63+sign-bit addition and subtraction with overflow checks, without using built-ins. It's a fallback for when __builtin_saddll_overflow and __builtin_ssubll_overflow are not available.
Allows 63+sign-bit integers in Script down the line.
Differential D9848
Add AddInt63OverflowEmulated and SubInt63OverflowEmulated tobias_ruck on Aug 5 2021, 02:08. Authored by Tags None Subscribers None
Details
Computes 63+sign-bit addition and subtraction with overflow checks, without using built-ins. It's a fallback for when __builtin_saddll_overflow and __builtin_ssubll_overflow are not available. Allows 63+sign-bit integers in Script down the line. ninja check
Diff Detail
Event Timeline
Comment Actions Inlined and removed intmath.cpp and intmath_util.h. Renamed functions in intmath.h. Fixed copyright notice. Simplified conditional code. Verified lack of UB with the following: set(CMAKE_CXX_FLAGS "-fsanitize=undefined") in CMakeLists.txt ninja test_bitcoin && ./src/test/test_bitcoin -t intmath_tests results in no runtime errors. Moving result = a + b; and result = a - b; in intmath.h in front of the overflow checks and testing again results in: Running 1 test case... ../src/./script/intmath.h:34:16: runtime error: signed integer overflow: -126 - 9223372036854775807 cannot be represented in type 'long long' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/./script/intmath.h:34:16 in ../src/./script/intmath.h:16:16: runtime error: signed integer overflow: 9223372036854775807 + 15325750 cannot be represented in type 'long long' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/./script/intmath.h:16:16 in Comment Actions Improve GenInt63, generates random positive uniform 63-bit number first, then maps to random uniform bit-length and then negates with 50% chance.
Comment Actions Build Bitcoin ABC Diffs / Diff Testing (build-debug) failed.
Failed tests logs: ====== Bitcoin ABC functional tests: abc_p2p_proof_inventory.py ====== ------- Stdout: ------- 2021-08-19T08:42:07.494000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_ _20210819_084204/abc_p2p_proof_inventory_1 2021-08-19T08:42:10.219000Z TestFramework (INFO): Test sending a proof to our peers 2021-08-19T08:42:15.519000Z TestFramework (INFO): Test that we don't send the same inv several times 2021-08-19T08:42:19.717000Z TestFramework (INFO): Test a peer is created on proof reception 2021-08-19T08:42:19.970000Z TestFramework (INFO): Test receiving a proof with missing utxo is orphaned 2021-08-19T08:42:36.595000Z TestFramework (INFO): Nodes should eventually get the proof from their peer 2021-08-19T08:43:37.040000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/work/test/functional/test_framework/test_framework.py", line 127, in main self.run_test() File "/work/test/functional/abc_p2p_proof_inventory.py", line 309, in run_test self.test_proof_relay() File "/work/test/functional/abc_p2p_proof_inventory.py", line 194, in test_proof_relay self.sync_proofs() File "/work/test/functional/test_framework/test_framework.py", line 598, in sync_proofs "".join("\n {!r}".format(m) for m in nodes_proofs), AssertionError: Proofs sync timed out after 60s: {6602570144918074808348643829737375459277018741439688339068130810910165091525, 4855606214566755611854941872008953586797068519770192445106571173944961724226} {6602570144918074808348643829737375459277018741439688339068130810910165091525, 4855606214566755611854941872008953586797068519770192445106571173944961724226} {13973555143603491866073812417028997900378547346586411321916985318209461542133, 48966920474268920273518024000965517207941241018457762983682481056232661307578, 54765853492931327955993243584528671492237549707396256159560862334732186751282, 4855606214566755611854941872008953586797068519770192445106571173944961724226} {13973555143603491866073812417028997900378547346586411321916985318209461542133, 48966920474268920273518024000965517207941241018457762983682481056232661307578, 54765853492931327955993243584528671492237549707396256159560862334732186751282, 4855606214566755611854941872008953586797068519770192445106571173944961724226} {13973555143603491866073812417028997900378547346586411321916985318209461542133, 4855606214566755611854941872008953586797068519770192445106571173944961724226, 54765853492931327955993243584528671492237549707396256159560862334732186751282, 48966920474268920273518024000965517207941241018457762983682481056232661307578} 2021-08-19T08:43:37.090000Z TestFramework (INFO): Stopping nodes 2021-08-19T08:43:37.295000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_ _20210819_084204/abc_p2p_proof_inventory_1 2021-08-19T08:43:37.295000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_ _20210819_084204/abc_p2p_proof_inventory_1/test_framework.log 2021-08-19T08:43:37.295000Z TestFramework (ERROR): 2021-08-19T08:43:37.295000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-debug/test/tmp/test_runner_₿₵_ _20210819_084204/abc_p2p_proof_inventory_1' to consolidate all logs 2021-08-19T08:43:37.295000Z TestFramework (ERROR): 2021-08-19T08:43:37.295000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log. 2021-08-19T08:43:37.295000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues 2021-08-19T08:43:37.295000Z TestFramework (ERROR): Each failure log is accessible here:
|