Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fanquake opened this issue Jul 12, 2023 · 5 comments
Closed

Comments

@fanquake
Copy link
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.

@maflcko
Copy link
Member

maflcko commented Jul 12, 2023

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)

@maflcko maflcko added the P2P label Jul 12, 2023
@maflcko
Copy link
Member

maflcko commented Jul 12, 2023

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

@maflcko
Copy link
Member

maflcko commented Jul 12, 2023

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
}

@fanquake
Copy link
Member Author

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

@maflcko
Copy link
Member

maflcko commented Jul 17, 2023

Ok, let's continue discussion there.

@maflcko maflcko closed this as completed Jul 17, 2023
fanquake added a commit to fanquake/bitcoin that referenced this issue Jul 25, 2023
Now that https://bugs.kde.org/show_bug.cgi?id=472219 has been fixed
upstream in:

https://sourceware.org/git/?p=valgrind.git;a=commit;h=6ce0979884a8f246c80a098333ceef1a7b7f694d

Add a supression to ignore the bug until we are using a fixed version of
Valgrind.

Related to bitcoin#28072.
fanquake added a commit to fanquake/bitcoin that referenced this issue Jul 25, 2023
Now that https://bugs.kde.org/show_bug.cgi?id=472219 has been fixed
upstream in:

https://sourceware.org/git/?p=valgrind.git;a=commit;h=6ce0979884a8f246c80a098333ceef1a7b7f694d

Add a supression to ignore the bug until we are using a fixed version of
Valgrind.

Related to bitcoin#28072.
fanquake added a commit that referenced this issue Jul 26, 2023
50f7214 valgrind: add suppression for bug 472219 (fanquake)

Pull request description:

  Now that https://bugs.kde.org/show_bug.cgi?id=472219 has been fixed upstream in:

  https://sourceware.org/git/?p=valgrind.git;a=commit;h=6ce0979884a8f246c80a098333ceef1a7b7f694d

  Add a supression to ignore the bug until we are using a fixed version of Valgrind.

  Related to #28072.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 50f7214

Tree-SHA512: 1030f3709195250350fd9c558420a9b1773fb54fdb323e0452a46eeb69ec6d60b5df50bde617c12d917e16dde07db64dee1b0101ddd4eda6161261fc7f6d4474
sidhujag pushed a commit to syscoin/syscoin that referenced this issue Aug 9, 2023
50f7214 valgrind: add suppression for bug 472219 (fanquake)

Pull request description:

  Now that https://bugs.kde.org/show_bug.cgi?id=472219 has been fixed upstream in:

  https://sourceware.org/git/?p=valgrind.git;a=commit;h=6ce0979884a8f246c80a098333ceef1a7b7f694d

  Add a supression to ignore the bug until we are using a fixed version of Valgrind.

  Related to bitcoin#28072.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 50f7214

Tree-SHA512: 1030f3709195250350fd9c558420a9b1773fb54fdb323e0452a46eeb69ec6d60b5df50bde617c12d917e16dde07db64dee1b0101ddd4eda6161261fc7f6d4474
eriknylund pushed a commit to eriknylund/bitcoin that referenced this issue Aug 17, 2023
Now that https://bugs.kde.org/show_bug.cgi?id=472219 has been fixed
upstream in:

https://sourceware.org/git/?p=valgrind.git;a=commit;h=6ce0979884a8f246c80a098333ceef1a7b7f694d

Add a supression to ignore the bug until we are using a fixed version of
Valgrind.

Related to bitcoin#28072.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants