NULL ptr deref when press Ctrl+C right after starting bitcoind #1294

issue wizeman opened this issue on May 14, 2012
  1. wizeman commented at 4:05 AM on May 14, 2012: contributor

    Using bitcoin tag v0.6.2.2, if I press Ctrl+C right after starting bitcoind, it crashes:

    Core was generated by `./bitcoind -dns -connect=10.210.1.1'.
    Program terminated with signal 6, Aborted.
    [#0](/bitcoin-bitcoin/0/)  0x00007fa828e9e3a5 in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
    64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
            in ../nptl/sysdeps/unix/sysv/linux/raise.c
    (gdb) bt
    [#0](/bitcoin-bitcoin/0/)  0x00007fa828e9e3a5 in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
    [#1](/bitcoin-bitcoin/1/)  0x00007fa828ea1b0b in __GI_abort () at abort.c:92
    [#2](/bitcoin-bitcoin/2/)  0x00007fa82c382f38 in undefined_behavior_trap_handler ()
    [#3](/bitcoin-bitcoin/3/)  0x00007fa82c139d79 in StopNode () at net.cpp:1707
    [#4](/bitcoin-bitcoin/4/)  0x00007fa82bfcb6fb in Shutdown (parg=<optimized out>) at init.cpp:58
    [#5](/bitcoin-bitcoin/5/)  0x00007fa82bfcbcd2 in AppInit (argc=<optimized out>, argv=<optimized out>) at init.cpp:118
    [#6](/bitcoin-bitcoin/6/)  0x00007fa82bfcbc3a in main (argc=<optimized out>, argv=<optimized out>) at init.cpp:96
    

    The relevant lines of code around net.cpp:1707:StopNode():

    1700 bool StopNode()
    1701 {
    1702     printf("StopNode()\n");
    1703     fShutdown = true;
    1704     nTransactionsUpdated++;
    1705     int64 nStart = GetTime();
    1706     for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
    1707          semOutbound->post();
    

    The reason seems to be that semOutbound has not been initialized yet:

    (gdb) p semOutbound
    $1 = 0
    

    In other words, StopNode() is being called before StartNode().

  2. Diapolo commented at 6:55 AM on May 14, 2012: none

    This should be fixed in the current master, as there now is a check included: https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1903

  3. wizeman commented at 1:48 PM on May 14, 2012: contributor

    Thanks, I will close the issue now.

  4. wizeman closed this on May 14, 2012

  5. DrahtBot locked this on Sep 8, 2021

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: 2026-04-13 21:16 UTC

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