vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
240 stars 52 forks source link

fix(test): tor transport test fails with SIGSEGV on macOS M1 #1105

Closed diegomrsantos closed 1 month ago

diegomrsantos commented 1 month ago

When running the testtortransport locally on macOS, it fails with the following error:

Tor transport WRN 2024-05-27 20:05:11.446+02:00 TCP transport already stopped              topics="libp2p tcptransport" tid=117174872
.WRN 2024-05-27 20:05:11.448+02:00 TCP transport already stopped              topics="libp2p tcptransport" tid=117174872
.WRN 2024-05-27 20:05:11.450+02:00 TCP transport already stopped              topics="libp2p tcptransport" tid=117174872
.WRN 2024-05-27 20:05:11.467+02:00 TCP transport already stopped              topics="libp2p tcptransport" tid=117174872
.WRN 2024-05-27 20:05:11.469+02:00 TCP transport already stopped              topics="libp2p tcptransport" tid=117174872
..WRN 2024-05-27 20:05:11.471+02:00 TCP transport already stopped              topics="libp2p tcptransport" tid=117174872
Traceback (most recent call last)
/nim-libp2p/nimbledeps/pkgs/unittest2-#2300fa9924a76e6c96bc4ea79d043e3a0f27120c/unittest2.nim(1151) testtortransport
/nim-libp2p/nimbledeps/pkgs/unittest2-#2300fa9924a76e6c96bc4ea79d043e3a0f27120c/unittest2.nim(1074) runDirect
/workspace/nim-libp2p/tests/helpers.nim(55) runTest`gensym308
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: '/nim-libp2p/tests/testnative '
diegomrsantos commented 1 month ago

Adding more context, this error happened randomly when running the test alone and all the time when running nimble test. It's unclear what the problem is and why the suggested changes fix it.

My laptop was generally slow, and after investigating more, I found that qemu was using 14GB of memory. After killing the process, it wasn't possible to reproduce the problem anymore.

diegomrsantos commented 1 month ago

LGTM. Thank you.

more context: this is necessary for #1099 (see description)

Let's open an issue regarding investigating this error further.

Now that I know the problem was due to some unusually big memory consumption on my laptop, I'm not sure it's worth it to merge this hack. I did it cause I didn't know any better, but closing qemu and restarting the laptop fixed the problem.

kaiserd commented 1 month ago

Thanks for the investigation. Closing this since the main problem this PR addressed is not occurring anymore. We still should investigate the root cause in the future (adding to ice-box).