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

Segmentation fault: 11 when closing other MIDI-Applications (like Koala-Sampler or DLS-Midi Synth) #5

Open
scrbblr opened this issue Aug 11, 2021 · 1 comment

Comments

@scrbblr
Copy link

scrbblr commented Aug 11, 2021

Node.js exits with a "segmentation fault: 11"-Error when closing a midi-application whose (virtual) midi-ports where already recognized by JZZ's watcher.

This happens when JZZ.js runs within my node application, then I open e.g. the DLS-Midi Synth App on Mac and the port 'DLS-MIDI-Synth Virtual In' shows up in JZZ's list of available ports. Now, when I close the DLS-Midi Synth App, my node application exits with the segmentation fault.

There seems to be a problem with the watcher and the MidiOutInfo method calling the compiled jazz-midi/bin/11_15/macos64/jazz.node gyp. And it seems to be related to virtual ports that weren't created by JZZ.

Reinstalling all node_modules didn't fix it.

Running node.js v16.1.0 on Mac 10.14.6. The jzz version is 1.3.8, the jazz-midi version is 1.7.5.

Here the log:

PID 15144 received SIGSEGV for address: 0x0
0   segfault-handler.node               0x000000010e172006 _ZL16segfault_handleriP9__siginfoPv + 310
1   libsystem_platform.dylib            0x00007fff5b9a5b5d _sigtramp + 29
2   CoreFoundation                      0x00007fff8a9618f0 __kCFAllocatorSystemDefault + 0
3   jazz.node                           0x000000010e1a4d15 _ZN11CMidiMacOSX11MidiOutInfoEPKw + 245
4   jazz.node                           0x000000010e198c0d _Z11MidiOutInfoP10napi_env__P20napi_callback_info__ + 541
5   node                                0x000000010923168a _ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE + 122
6   node                                0x0000000109463275 _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE + 613
7   node                                0x0000000109462848 _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE + 824
8   node                                0x0000000109461dff _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE + 255
9   node                                0x0000000109ceb7b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit + 57
10  node                                0x0000000109c861e5 Builtins_InterpreterEntryTrampoline + 197
Segmentation fault: 11

How to reproduce the issue:

  1. Open a midi-application like Koala Sampler or DLS-Midi-Synth.

  2. Call following node script:

const navigator = require('jzz'); 

navigator.requestMIDIAccess({sysex: true}).then((access)=>{
  console.log(Array.from(access.inputs.values()), Array.from(access.outputs.values())); 
}, (err)=>{console.log(err)});
  1. Close the midi-application.
thirtythreeforty added a commit to thirtythreeforty/jazz-midi that referenced this issue Oct 10, 2023
The pthread and lock are never created if the "if" in the constructor
fails, and the members are never initialized.  But the destructor
unconditionally destroys them.  Fix this by adding a guard flag.

This fixes a segfault I encountered on Arch with Pipewire as the ALSA
server.

    Thread 1 "node" received signal SIGSEGV, Segmentation fault.
    0x00007ffff428aebd in pthread_cancel () from /usr/bin/../lib/libc.so.6
    (gdb) bt
    #0  0x00007ffff428aebd in pthread_cancel () from /usr/bin/../lib/libc.so.6
    jazz-soft#1  0x00007ffff3b773ff in CMidiInHW::~CMidiInHW (this=0x55555572a430, __in_chrg=<optimized out>) at ../../midi/MidiALSA.cpp:366
    jazz-soft#2  0x00007ffff3b77452 in CMidiInHW::~CMidiInHW (this=0x55555572a430, __in_chrg=<optimized out>) at ../../midi/MidiALSA.cpp:369
    jazz-soft#3  0x00007ffff3b77105 in CMidiALSA::MidiInOpen[abi:cxx11](wchar_t const*, void*) (this=0x5555557b9880, name=0x5555556b3cf0 L"input", p=0x55555579e3a0) at ../../midi/MidiALSA.cpp:329
    jazz-soft#4  0x00007ffff3b6f0c8 in MidiInOpen (env=0x55555579e410, args=0x7fffffff9e20) at ../jazz-midi.cpp:461
    jazz-soft#5  0x00007ffff535bd33 in ?? () from /usr/bin/../lib/libnode.so.115
    jazz-soft#6  0x00007ffff5840d97 in ?? () from /usr/bin/../lib/libnode.so.115
    jazz-soft#7  0x00007ffff5841942 in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) () from /usr/bin/../lib/libnode.so.115
    jazz-soft#8  0x00007ffff56cadf6 in ?? () from /usr/bin/../lib/libnode.so.115
@djipco
Copy link

djipco commented Nov 4, 2023

This problem has also been reported in the WEBMIDI.js repo (which uses jazz-midi under the hood to add Node.js support).

Details here: djipco/webmidi#391

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

No branches or pull requests

2 participants