tests: Add initialization order fiasco detection in Travis #17674

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:initialization-order-fiasco changing 1 files +1 −1
  1. practicalswift commented at 10:56 am on December 5, 2019: contributor

    Add initialization order fiasco detection in Travis :)

    Context: #17670 (comment)

    This would have caught the events_hasher initialization order issue introduced in #17573 and fixed in #17670.

    Output in case of an initialization order fiasco:

     0==7934==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x557098d79200 at pc 0x55709796b9a3 bp 0x7ffde524dc30 sp 0x7ffde524dc28
     1READ of size 8 at 0x557098d79200 thread T0
     2    [#0](/bitcoin-bitcoin/0/) 0x55709796b9a2 in CSHA256::Finalize(unsigned char*) src/crypto/sha256.cpp:667:25
     3    [#1](/bitcoin-bitcoin/1/) 0x5570978150e9 in SeedEvents(CSHA512&) src/random.cpp:462:19
     4    [#2](/bitcoin-bitcoin/2/) 0x5570978145e1 in SeedSlow(CSHA512&) src/random.cpp:482:5
     5    [#3](/bitcoin-bitcoin/3/) 0x5570978149a3 in SeedStartup(CSHA512&, (anonymous namespace)::RNGState&) src/random.cpp:527:5
     6    [#4](/bitcoin-bitcoin/4/) 0x55709781102d in ProcRand(unsigned char*, int, RNGLevel) src/random.cpp:571:9
     7    [#5](/bitcoin-bitcoin/5/) 0x557097810d19 in GetRandBytes(unsigned char*, int) src/random.cpp:576:59
     8    [#6](/bitcoin-bitcoin/6/) 0x557096c2f9d5 in (anonymous namespace)::CSignatureCache::CSignatureCache() src/script/sigcache.cpp:34:9
     9    [#7](/bitcoin-bitcoin/7/) 0x557096511977 in __cxx_global_var_init.7 src/script/sigcache.cpp:67:24
    10    [#8](/bitcoin-bitcoin/8/) 0x5570965119f8 in _GLOBAL__sub_I_sigcache.cpp src/script/sigcache.cpp
    11    [#9](/bitcoin-bitcoin/9/) 0x557097bba4ac in __libc_csu_init (src/bitcoind+0x18554ac)
    12    [#10](/bitcoin-bitcoin/10/) 0x7f214b1c2b27 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:266
    13    [#11](/bitcoin-bitcoin/11/) 0x5570965347d9 in _start (src/bitcoind+0x1cf7d9)
    14
    150x557098d79200 is located 96 bytes inside of global variable 'events_hasher' defined in 'random.cpp:456:16' (0x557098d791a0) of size 104
    16  registered at:
    17    [#0](/bitcoin-bitcoin/0/) 0x557096545dfd in __asan_register_globals compiler-rt/lib/asan/asan_globals.cpp:360:3
    18    [#1](/bitcoin-bitcoin/1/) 0x557097817f8b in asan.module_ctor (src/bitcoind+0x14b2f8b)
    19
    20SUMMARY: AddressSanitizer: initialization-order-fiasco src/crypto/sha256.cpp:667:25 in CSHA256::Finalize(unsigned char*)
    
  2. tests: Add initialization order fiasco detection in Travis 1f9d5af4f1
  3. laanwj added the label Tests on Dec 5, 2019
  4. practicalswift commented at 11:24 am on December 5, 2019: contributor

    Fails as expected for the two ASAN jobs in Travis:

     0make[3]: *** [test/amount_tests.cpp.test] Error 1
     1Makefile:14006: recipe for target 'test/amount_tests.cpp.test' failed
     2=================================================================
     3==25881==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x55e6e8811540 at pc 0x55e6e3f3e333 bp 0x7fff60848af0 sp 0x7fff60848ae8
     4READ of size 8 at 0x55e6e8811540 thread T0
     5    [#0](/bitcoin-bitcoin/0/) 0x55e6e3f3e332 in CSHA256::Finalize(unsigned char*) /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/crypto/sha256.cpp:667:25
     6    [#1](/bitcoin-bitcoin/1/) 0x55e6e3e63905 in SeedEvents(CSHA512&) /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/random.cpp:462:19
     7    [#2](/bitcoin-bitcoin/2/) 0x55e6e3e62dd3 in SeedSlow(CSHA512&) /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/random.cpp:482:5
     8    [#3](/bitcoin-bitcoin/3/) 0x55e6e3e634cf in SeedStartup(CSHA512&, (anonymous namespace)::RNGState&) /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/random.cpp:527:5
     9    [#4](/bitcoin-bitcoin/4/) 0x55e6e3e5fddc in ProcRand(unsigned char*, int, RNGLevel) /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/random.cpp:571:9
    10    [#5](/bitcoin-bitcoin/5/) 0x55e6e3e5fba1 in GetRandBytes(unsigned char*, int) /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/random.cpp:576:59
    11    [#6](/bitcoin-bitcoin/6/) 0x55e6e2682563 in (anonymous namespace)::CSignatureCache::CSignatureCache() /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/script/sigcache.cpp:34:9
    12    [#7](/bitcoin-bitcoin/7/) 0x55e6e2682563 in __cxx_global_var_init.11 /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/script/sigcache.cpp:67
    13    [#8](/bitcoin-bitcoin/8/) 0x55e6e2682563 in _GLOBAL__sub_I_sigcache.cpp /home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/script/sigcache.cpp
    14    [#9](/bitcoin-bitcoin/9/) 0x55e6e44a2e1c in __libc_csu_init (/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/test/test_bitcoin+0x4911e1c)
    15    [#10](/bitcoin-bitcoin/10/) 0x7fe2b094eb27 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b27)
    16    [#11](/bitcoin-bitcoin/11/) 0x55e6e2698bd9 in _start (/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/test/test_bitcoin+0x2b07bd9)
    170x55e6e8811540 is located 96 bytes inside of global variable 'events_hasher' defined in 'random.cpp:456:16' (0x55e6e88114e0) of size 104
    18  registered at:
    19    [#0](/bitcoin-bitcoin/0/) 0x55e6e26aa5de in __asan_register_globals (/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/test/test_bitcoin+0x2b195de)
    20    [#1](/bitcoin-bitcoin/1/) 0x55e6e3e652bb in asan.module_ctor (/home/travis/build/bitcoin/bitcoin/build/bitcoin-x86_64-pc-linux-gnu/src/test/test_bitcoin+0x42d42bb)
    
  5. laanwj commented at 11:29 am on December 5, 2019: member

    Concept ACK!

    Does this pass with #17670 or are there other initialization order fiasco in the code?

  6. practicalswift commented at 11:31 am on December 5, 2019: contributor
    @laanwj Travis passes with #17670, so this is the only fiasco in our code :)
  7. promag commented at 2:29 pm on December 5, 2019: member

    Tested ACK 1f9d5af4f197e7cc0469a0bb25dcbc51dfa537f4, got

    0==3770==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x0001058f70a0 at pc 0x000105542404 bp 0x7ffeeb534ef0 sp 0x7ffeeb534ee8
    1READ of size 8 at 0x0001058f70a0 thread T0
    2    [#0](/bitcoin-bitcoin/0/) 0x105542403 in CSHA256::Finalize(unsigned char*) sha256.cpp:667
    3    [#1](/bitcoin-bitcoin/1/) 0x105433ca0 in SeedEvents(CSHA512&) random.cpp:462
    4    [#2](/bitcoin-bitcoin/2/) 0x1054300f6 in ProcRand(unsigned char*, int, RNGLevel) random.cpp:482
    5    [#3](/bitcoin-bitcoin/3/) 0x10542f99a in GetRandBytes(unsigned char*, int) random.cpp:576
    6    [#4](/bitcoin-bitcoin/4/) 0x104bfcce5 in _GLOBAL__sub_I_sigcache.cpp sigcache.cpp:34
    

    Probably rebase with #17670 to have CI green.

  8. MarcoFalke commented at 6:13 pm on December 5, 2019: member

    ACK 1f9d5af4f197e7cc0469a0bb25dcbc51dfa537f4 👔

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3ACK 1f9d5af4f197e7cc0469a0bb25dcbc51dfa537f4 👔
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUggBgv/WX2CjAhXVFCzZxEXZNk/ypMrUPN0Jg6iclVN5cpR2G7AVGTdiJUCYxCR
     8TDky/yYSl/soc+Zd8odXNOPIJAP6azPWmD2a7J8ttMB4iCmgQvPQxXarIEKQrC7b
     9cOU+yNTOe2tNkooir9ZoP6ay8z0GFxa1tsflRipGWeJEZqiLMM1nJo6e9qvfF7lN
    10MldOOAHo07B4+nmi/7w0Pj6GYfxF9OT17HHkhMiFjaYc+ezBaAbyNRTT/iH7L9dv
    117s3d+2Qp2DLE0YvBuofAkNUkeVtg/AU6iKYnUzkNWCxsrhmpmfYG/YLb+wcxYwRI
    12FwvMNqPQMB+e6E55njqpIkWwsnvhK68ewgAmFTVFJ2mDDmg0mGQV8KEX9Lorjjm3
    13ZdJD+3DxAn8VfhTQQFS5iS1LTkXPFkZ8y/GHUwX0GBuYNKClpFSGyZe+mKHZK3fU
    14YkRY7+eVhw6Eg7QkFud9xZ7/IEp8SZWtvfNvBWHAuJGVK/zyzLI+j3bgRUQiXqM+
    15z2r0XTcX
    16=3Nui
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 97c46147814b07ad0e4976949b09e8d622a974ee6005483703d819bc30b4ccb4 -

  9. MarcoFalke referenced this in commit cf43f3f0a8 on Dec 5, 2019
  10. MarcoFalke merged this on Dec 5, 2019
  11. MarcoFalke closed this on Dec 5, 2019

  12. MarcoFalke referenced this in commit 7027c67cac on Jul 2, 2020
  13. deadalnix referenced this in commit 929b49252f on Dec 28, 2020
  14. deadalnix referenced this in commit 3977ecf92c on Dec 29, 2020
  15. practicalswift deleted the branch on Apr 10, 2021
  16. vijaydasmp referenced this in commit dfa262c93f on Oct 4, 2021
  17. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

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 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me