valgrind: Syscall param ppoll(ufds.events) points to uninitialised byte(s) #28072

issue fanquake opened this issue on July 12, 2023
  1. fanquake commented at 2:12 PM on July 12, 2023: member

    Using master, GCC 12.2.1, Valgrind 3.21.0 (system), aarch64, Alpine Linux (musl libc):

    ./test/functional/test_runner.py --combinedlogslen=19999 --timeout-factor=12 --jobs=9 --valgrind
    ...
    24/268 - p2p_dns_seeds.py failed, Duration: 9 s
    ....
     node0 2023-07-12T12:59:04.448921Z [init] [noui.cpp:56] [noui_InitMessage] init message: Done loading 
     node0 2023-07-12T12:59:04.453823Z [addcon] [util/thread.cpp:20] [TraceThread] addcon thread start 
     node0 2023-07-12T12:59:04.456041Z [msghand] [util/thread.cpp:20] [TraceThread] msghand thread start 
     test  2023-07-12T12:59:04.763000Z TestFramework.node0 (DEBUG): Stopping node 
     test  2023-07-12T12:59:04.763000Z TestFramework (ERROR): Assertion failed 
                                       Traceback (most recent call last):
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 552, in start_nodes
                                           node.wait_for_rpc_connection()
                                         File "/bitcoin/test/functional/test_framework/test_node.py", line 235, in wait_for_rpc_connection
                                           raise FailedToStartError(self._node_msg(
                                       test_framework.test_node.FailedToStartError: [node 0] bitcoind exited with status 1 during initialization
                                       During handling of the above exception, another exception occurred:
                                       Traceback (most recent call last):
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 130, in main
                                           self.setup()
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 295, in setup
                                           self.setup_network()
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 389, in setup_network
                                           self.setup_nodes()
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 411, in setup_nodes
                                           self.start_nodes()
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 555, in start_nodes
                                           self.stop_nodes()
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 570, in stop_nodes
                                           node.stop_node(wait=wait, wait_until_stopped=False)
                                         File "/bitcoin/test/functional/test_framework/test_node.py", line 346, in stop_node
                                           self.stop(wait=wait)
                                           ^^^^^^^^^
                                         File "/bitcoin/test/functional/test_framework/test_node.py", line 192, in __getattr__
                                           assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
                                                                         ^^^^^^^^^^^^^^^^^^^^
                                       AssertionError: [node 0] Error: no RPC connection
     test  2023-07-12T12:59:04.764000Z TestFramework (DEBUG): Closing down network thread 
     test  2023-07-12T12:59:04.814000Z TestFramework (INFO): Stopping nodes 
     test  2023-07-12T12:59:04.814000Z TestFramework.node0 (DEBUG): Stopping node 
    
     node0 stderr ==30770== Thread 16 b-dnsseed:
    ==30770== Syscall param ppoll(ufds.events) points to uninitialised byte(s)
    ==30770==    at 0x405DCCC: ??? (in /lib/ld-musl-aarch64.so.1)
    ==30770==  Address 0x7d219a4 is on thread 16's stack
    ==30770== 
    {
       <insert_a_suppression_name_here>
       Memcheck:Param
       ppoll(ufds.events)
       obj:/lib/ld-musl-aarch64.so.1
    }
    ==30770== 
    ==30770== Exit program on first error (--exit-on-first-error=yes) 
    
    254/268 - feature_config_args.py failed, Duration: 20 s
    ....
     node0 2023-07-12T13:16:16.303713Z [opencon] [util/thread.cpp:20] [TraceThread] opencon thread start 
     node0 2023-07-12T13:16:16.309602Z [opencon] [net.cpp:1633] [ThreadOpenConnections] Fixed seeds are disabled 
     test  2023-07-12T13:16:16.366000Z TestFramework (ERROR): Unexpected exception caught during testing 
                                       Traceback (most recent call last):
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
                                           self.run_test()
                                         File "/bitcoin/test/functional/feature_config_args.py", line 376, in run_test
                                           self.test_args_log()
                                         File "/bitcoin/test/functional/feature_config_args.py", line 182, in test_args_log
                                           self.start_node(0, extra_args=[
                                         File "/bitcoin/test/functional/test_framework/test_framework.py", line 537, in start_node
                                           node.wait_for_rpc_connection()
                                         File "/bitcoin/test/functional/test_framework/test_node.py", line 235, in wait_for_rpc_connection
                                           raise FailedToStartError(self._node_msg(
                                       test_framework.test_node.FailedToStartError: [node 0] bitcoind exited with status 1 during initialization
     test  2023-07-12T13:16:16.367000Z TestFramework (DEBUG): Closing down network thread 
     test  2023-07-12T13:16:16.417000Z TestFramework (INFO): Stopping nodes 
     test  2023-07-12T13:16:16.417000Z TestFramework.node0 (DEBUG): Stopping node 
    
     node0 stderr ==41539== Thread 15 b-addcon:
    ==41539== Syscall param ppoll(ufds.events) points to uninitialised byte(s)
    ==41539==    at 0x405DCCC: ??? (in /lib/ld-musl-aarch64.so.1)
    ==41539==  Address 0x8121724 is on thread 15's stack
    ==41539== 
    {
       <insert_a_suppression_name_here>
       Memcheck:Param
       ppoll(ufds.events)
       obj:/lib/ld-musl-aarch64.so.1
    }
    ==41539== 
    ==41539== Exit program on first error (--exit-on-first-error=yes) 
    

    Full logs: https://gist.github.com/fanquake/8e8ce3efcdbf77a85103a36c29c3e68c. Looking at other discussion, seems like this is likely a Valgrind false-positive, so we may just want to suppress.

  2. maflcko added the label Tests on Jul 12, 2023
  3. maflcko added the label Upstream on Jul 12, 2023
  4. maflcko commented at 3:42 PM on July 12, 2023: member

    To reproduce without tests:

    # valgrind --gen-suppressions=all --quiet --error-exitcode=1 --suppressions=$PWD/contrib/valgrind.supp --exit-on-first-error=yes ./src/bitcoind -regtest -noconnect -addnode=some.node  -printtoconsole=0
    ==47801== Thread 25 b-addcon:
    ==47801== Syscall param ppoll(ufds.events) points to uninitialised byte(s)
    ==47801==    at 0x405DCCC: ??? (in /lib/ld-musl-aarch64.so.1)
    ==47801==  Address 0x823b724 is on thread 25's stack
    ==47801== 
    {
       <insert_a_suppression_name_here>
       Memcheck:Param
       ppoll(ufds.events)
       obj:/lib/ld-musl-aarch64.so.1
    }
    ==47801== 
    ==47801== Exit program on first error (--exit-on-first-error=yes)
    
  5. maflcko added the label P2P on Jul 12, 2023
  6. maflcko commented at 3:46 PM on July 12, 2023: member

    Maybe someone can transform this into a standalone minimal cpp file to submit to valgrind or musl?

  7. maflcko commented at 4:21 PM on July 12, 2023: member

    Done:

    /bitcoin-core # cat /tmp/a.cpp 
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netdb.h>
    
    int main(){
        addrinfo ai_hint{};
        ai_hint.ai_socktype = SOCK_STREAM;
        ai_hint.ai_protocol = IPPROTO_TCP;
        ai_hint.ai_family = AF_UNSPEC;
        ai_hint.ai_flags = true? AI_ADDRCONFIG : AI_NUMERICHOST;
        addrinfo* ai_res{nullptr};
        return getaddrinfo("foo.bar", nullptr, &ai_hint, &ai_res);
    }
    /bitcoin-core # clang++  /tmp/a.cpp -o /tmp/exe && valgrind --gen-suppressions=all --quiet /tmp/exe 
    ==77232== Syscall param ppoll(ufds.events) points to uninitialised byte(s)
    ==77232==    at 0x405DCCC: ??? (in /lib/ld-musl-aarch64.so.1)
    ==77232==  Address 0x1ffefff804 is on thread 1's stack
    ==77232== 
    {
       <insert_a_suppression_name_here>
       Memcheck:Param
       ppoll(ufds.events)
       obj:/lib/ld-musl-aarch64.so.1
    }
    
  8. fanquake commented at 1:20 PM on July 13, 2023: member

    Opened a bug report with Valgrind: https://bugs.kde.org/show_bug.cgi?id=472219

  9. maflcko commented at 6:49 AM on July 17, 2023: member

    Ok, let's continue discussion there.

  10. maflcko closed this on Jul 17, 2023

  11. fanquake referenced this in commit 0e6e628260 on Jul 25, 2023
  12. fanquake referenced this in commit 50f7214e09 on Jul 25, 2023
  13. fanquake referenced this in commit 95d523fabb on Jul 26, 2023
  14. sidhujag referenced this in commit 547b683157 on Aug 9, 2023
  15. eriknylund referenced this in commit ea56e1f46e on Aug 17, 2023
  16. bitcoin locked this on Jul 16, 2024

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-17 00:13 UTC

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