iron-fish / ironfish

A novel cryptocurrency focused on privacy and accessibility.
https://ironfish.network
Mozilla Public License 2.0
965 stars 574 forks source link

PID 92682 received SIGSEGV for address: 0x9b70a0c4d1e0 #1625

Open wd021 opened 2 years ago

wd021 commented 2 years ago

What happened?

@NullSoldier reported this same bug last year https://github.com/iron-fish/ironfish/issues/145. At the time, we were using SimplePeer for webrtc communication. This PR https://github.com/iron-fish/ironfish/pull/144 fixed the issue by replacing SimplePeer with an ironfish forked version.

We've since moved to node-datachannel and it seems like we're seeing this bug again with the onMessage callback in the data channel wrapper, https://github.com/murat-dogan/node-datachannel/blob/1875484cc7d6737f59407e4f15aabe119984a0e8/src/data-channel-wrapper.cpp#L396-L435.

Version

0.1.36

Debug output

No response

Relevant log output

PID 92682 received SIGSEGV for address: 0x9b70a0c4d1e0
0   segfault-handler.node               0x00000001079c534c _ZL16segfault_handleriP9__siginfoPv + 288
1   libsystem_platform.dylib            0x000000019e2754c4 _sigtramp + 56
2   libc++.1.dylib                      0x000000019e1af154 _ZNSt3__15mutex4lockEv + 16
3   libc++.1.dylib                      0x000000019e1af154 _ZNSt3__15mutex4lockEv + 16
4   node_datachannel.node               0x000000010fe9a068 _ZN18ThreadSafeCallback4Impl4callENSt3__18functionIFvP10napi_env__RNS1_6vectorIP12napi_value__NS1_9allocatorIS7_EEEEEEENS2_IFvRKN4Napi5ValueERKNSE_5ErrorEEEE + 72
5   node_datachannel.node               0x000000010fe99ee8 _ZN18ThreadSafeCallbackclENSt3__18functionIFvP10napi_env__RNS0_6vectorIP12napi_value__NS0_9allocatorIS6_EEEEEEENS1_IFvRKN4Napi5ValueERKNSD_5ErrorEEEE + 208
6   node_datachannel.node               0x000000010fe99d58 _ZN18ThreadSafeCallback4callENSt3__18functionIFvP10napi_env__RNS0_6vectorIP12napi_value__NS0_9allocatorIS6_EEEEEEE + 128
7   node_datachannel.node               0x000000010feb3de0 _ZNSt3__110__function6__funcIZN18DataChannelWrapper9onMessageERKN4Napi12CallbackInfoEE3$_4NS_9allocatorIS7_EEFvNS_7variantIJNS_6vectorISt4byteNS8_ISC_EEEENS_12basic_stringIcNS_11char_traitsIcEENS8_IcEEEEEEEEEclEOSK_ + 232
8   node_datachannel.node               0x000000010fefb32c _ZNK3rtc21synchronized_callbackIJNSt3__17variantIJNS1_6vectorISt4byteNS1_9allocatorIS4_EEEENS1_12basic_stringIcNS1_11char_traitsIcEENS5_IcEEEEEEEEE4callESD_ + 132
9   node_datachannel.node               0x000000010fef8300 _ZNK3rtc21synchronized_callbackIJNSt3__17variantIJNS1_6vectorISt4byteNS1_9allocatorIS4_EEEENS1_12basic_stringIcNS1_11char_traitsIcEENS5_IcEEEEEEEEEclESD_ + 120
10  node_datachannel.node               0x000000010fef7f50 _ZN3rtc4impl7Channel20flushPendingMessagesEv + 212
11  node_datachannel.node               0x000000010fefa374 _ZN3rtc4impl11DataChannel8incomingENSt3__110shared_ptrINS_7MessageEEE + 172
12  node_datachannel.node               0x000000010ff0ce1c _ZN3rtc4impl14PeerConnection14forwardMessageENSt3__110shared_ptrINS_7MessageEEE + 124
13  node_datachannel.node               0x000000010ff194f0 _ZZN3rtc9weak_bindIMNS_4impl14PeerConnectionEFvNSt3__110shared_ptrINS_7MessageEEEES2_JRKNS3_12placeholders4__phILi1EEEEEEDaOT_PT0_DpOT1_ENKUlDpOT_E_clIJS6_EEESE_SO_ + 112
14  node_datachannel.node               0x000000010fe927b0 _ZNK3rtc21synchronized_callbackIJNSt3__110shared_ptrINS_7MessageEEEEE4callES4_ + 60
15  node_datachannel.node               0x000000010fef1680 _ZNK3rtc21synchronized_callbackIJNSt3__110shared_ptrINS_7MessageEEEEEclES4_ + 72
16  node_datachannel.node               0x000000010ff04d04 _ZN3rtc4impl9Transport4recvENSt3__110shared_ptrINS_7MessageEEE + 56
17  node_datachannel.node               0x000000010ff2c43c _ZN3rtc4impl13SctpTransport11processDataEONSt3__16vectorISt4byteNS2_9allocatorIS4_EEEEtNS1_9PayloadIdE + 1336
18  node_datachannel.node               0x000000010ff2afc8 _ZN3rtc4impl13SctpTransport6doRecvEv + 496
19  node_datachannel.node               0x000000010ff302d4 _ZZN3rtc4impl9Processor7enqueueIMNS0_13SctpTransportEFvvEJPS3_EEEvOT_DpOT0_ENUlvE_clEv + 116
20  node_datachannel.node               0x000000010ff30140 _ZZN3rtc4impl10ThreadPool8scheduleIZNS0_9Processor7enqueueIMNS0_13SctpTransportEFvvEJPS5_EEEvOT_DpOT0_EUlvE_JEEENSt3__16futureINSF_13invoke_resultINSF_5decayIS9_E4typeEJDpNSI_ISB_E4typeEEE4typeEEENSF_6chrono10time_pointINSR_12steady_clockENSR_8durationIxNSF_5ratioILl1ELl1000000000EEEEEEESA_SD_ENUlvE_clEv + 24
21  node_datachannel.node               0x000000010ff26ff4 _ZNSt3__113packaged_taskIFvvEEclEv + 80
22  node_datachannel.node               0x000000010ff30e34 _ZN3rtc4impl10ThreadPool3runEv + 132
23  node_datachannel.node               0x000000010ff31a38 _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEENS_6__bindIMN3rtc4impl10ThreadPoolEFvvEJPSA_EEEEEEEEPvSG_ + 64
24  libsystem_pthread.dylib             0x000000019e25e26c _pthread_start + 148
25  libsystem_pthread.dylib             0x000000019e25908c thread_start + 8

Graffiti

wd021

lwisne commented 2 years ago

Have you seen this recently?

NullSoldier commented 1 year ago

The bug in #145 is different than the stack you posted. I also reproduced this here too

PID 16063 received SIGSEGV for address: 0x3871f8cfb9c8
0   segfault-handler.node               0x0000000105545354 _ZL16segfault_handleriP9__siginfoPv + 288
1   libsystem_platform.dylib            0x00000001bbbec4e4 _sigtramp + 56
2   ironfish-rust-nodejs.darwin-arm64.n 0x000000011304119c _ZN4napi15bindgen_runtime15module_register9custom_gc17h6d3b57ee2491e70eE + 28
3   ironfish-rust-nodejs.darwin-arm64.n 0x000000011304119c _ZN4napi15bindgen_runtime15module_register9custom_gc17h6d3b57ee2491e70eE + 28
4   node                                0x0000000100509524 _ZN6v8impl12_GLOBAL__N_118ThreadSafeFunction7AsyncCbEP10uv_async_s + 432
5   node                                0x0000000100e484c4 uv__async_io + 320
6   node                                0x0000000100e5a210 uv__io_poll + 1036
7   node                                0x0000000100e48954 uv_run + 380
8   node                                0x00000001004816d4 _ZN4node13SpinEventLoopEPNS_11EnvironmentE + 244
9   node                                0x00000001005cc280 _ZN4node6worker6Worker3RunEv + 1600
10  node                                0x00000001005cefe4 _ZZN4node6worker6Worker11StartThreadERKN2v820FunctionCallbackInfoINS2_5ValueEEEEN3$_38__invokeEPv + 56
11  libsystem_pthread.dylib             0x00000001bbbd5240 _pthread_start + 148
12  libsystem_pthread.dylib             0x00000001bbbd0024 thread_start + 8
zsh: segmentation fault  ironfish start