Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

segfault on make #1

Open
isaacs opened this Issue · 21 comments

6 participants

@isaacs

Here's the output:

node-waf configure clean build && node tests/node-usb-test.js
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for program gcc or cc           : /usr/bin/gcc 
Checking for gcc                         : ok  
Checking for node path                   : ok /Users/isaacs/.node_libraries 
Checking for node prefix                 : ok /usr/local 
Checking for libusb-1.0                  : yes 
Checking for library usb-1.0             : yes 
'configure' finished successfully (0.173s)
'clean' finished successfully (0.007s)
Waf: Entering directory `/Users/isaacs/dev-src/js/node-usb/build'
[1/3] cxx: src/node_usb.cc -> build/default/src/node_usb_1.o
[2/3] cxx: src/bindings.cc -> build/default/src/bindings_1.o
[3/3] cxx_link: build/default/src/node_usb_1.o build/default/src/bindings_1.o -> build/default/usb_bindings.node
ld: warning: directory '/lib' following -L not found
Waf: Leaving directory `/Users/isaacs/dev-src/js/node-usb/build'
'build' finished successfully (0.761s)
node-usb [../src/node_usb.cc:init() 21]: Initalizing NodeUsb
node-usb [../src/node_usb.cc:InitalizeAll() 6]: Entering
node-usb [../src/bindings.cc:InitalizeUsb() 80]: Entering
node-usb [../src/bindings.cc:InitalizeUsb() 146]: Leave
node-usb [../src/bindings.cc:InitalizeDevice() 288]: Entering...
node-usb [../src/bindings.cc:InitalizeDevice() 315]: Leave
{ LIBUSB_CLASS_PER_INTERFACE: 0,
  isLibusbInitalized: false,
  LIBUSB_CLASS_AUDIO: 1,
  LIBUSB_CLASS_COMM: 2,
  LIBUSB_CLASS_HID: 3,
  LIBUSB_CLASS_PRINTER: 7,
  LIBUSB_CLASS_PTP: 6,
  LIBUSB_CLASS_MASS_STORAGE: 8,
  LIBUSB_CLASS_HUB: 9,
  LIBUSB_CLASS_DATA: 10,
  LIBUSB_CLASS_VENDOR_SPEC: 255,
  LIBUSB_DT_DEVICE: 1,
  LIBUSB_DT_CONFIG: 2,
  LIBUSB_DT_STRING: 3,
  LIBUSB_DT_INTERFACE: 4,
  LIBUSB_DT_ENDPOINT: 5,
  LIBUSB_DT_HID: 33,
  LIBUSB_DT_REPORT: 34,
  LIBUSB_DT_PHYSICAL: 35,
  LIBUSB_DT_HUB: 41,
  LIBUSB_ENDPOINT_IN: 128,
  LIBUSB_ENDPOINT_OUT: 0,
  LIBUSB_TRANSFER_TYPE_CONTROL: 0,
  LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: 1,
  LIBUSB_TRANSFER_TYPE_BULK: 2,
  LIBUSB_TRANSFER_TYPE_INTERRUPT: 3,
  LIBUSB_ISO_SYNC_TYPE_NONE: 0,
  LIBUSB_ISO_SYNC_TYPE_ASYNC: 1,
  LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: 2,
  LIBUSB_ISO_SYNC_TYPE_SYNC: 3,
  LIBUSB_ISO_USAGE_TYPE_DATA: 0,
  LIBUSB_ISO_USAGE_TYPE_FEEDBACK: 1,
  LIBUSB_ISO_USAGE_TYPE_IMPLICIT: 2 }
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
node-usb [../src/bindings.cc:New() 335]: New Device object created
node-usb [../src/bindings.cc:Device() 319]: Assigning libusb_device structure to self
/bin/sh: line 1: 87285 Segmentation fault      node tests/node-usb-test.js
make: *** [make] Error 139

gdb says this about it:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00000001005f4237 in darwin_get_active_config_descriptor ()
@schakko
Owner

Seems to be a problem with MacOS X port libusb. Are you using libusb-1.0?

@isaacs

Yeah. Installed with brew install libusb.

$ find /usr/local -name libusb*
/usr/local/Cellar/libusb
/usr/local/Cellar/libusb/1.0.8/include/libusb-1.0
/usr/local/Cellar/libusb/1.0.8/include/libusb-1.0/libusb.h
/usr/local/Cellar/libusb/1.0.8/lib/libusb-1.0.0.dylib
/usr/local/Cellar/libusb/1.0.8/lib/libusb-1.0.a
/usr/local/Cellar/libusb/1.0.8/lib/libusb-1.0.dylib
/usr/local/Cellar/libusb/1.0.8/lib/pkgconfig/libusb-1.0.pc
/usr/local/include/libusb-1.0
/usr/local/include/libusb.h
/usr/local/lib/libusb-1.0.0.dylib
/usr/local/lib/libusb-1.0.a
/usr/local/lib/libusb-1.0.dylib
/usr/local/lib/pkgconfig/libusb-1.0.pc
/usr/local/Library/Formula/libusb-compat.rb
/usr/local/Library/Formula/libusb.rb
@schakko
Owner

It's default difficult for me to further investigate 'cause I did not use MacOS X. Do you have some ideas how to solve the problem ?

@isaacs

I'll take a closer look at the code in a few days. I don't have time right now to step through it.

It looks like the old reading-from-a-null-pointer issue.

@schakko
Owner

Please try the latest commit.

@TooTallNate

Still doesn't work for me on OS X. Additionally, I had to modify the wscript file to look for "libusb" in /usr/local/ instead of just /usr/. I don't know the waf syntax, but you should be using the value found during the "configure" stage instead of hard-coding the location.

@rhiokim

First Step
Check user .bash or .bash_profile
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig defined on your .bash file

Second Step
installed with brew install libusb

Third Step
download lastest node-usb

And Last Step
$ ~/path/to/node-usb
$ make

I have successed

@TooTallNate

Just to clarify, I can build the module, but running either node tests/node-usb-test.js or node examples/lsusb.js gives a Segmentation fault.

@schakko
Owner

@TooTallNate
Please try to compile node-usb with
make debug
or
node-waf clean configure --debug=true build

and report the logged events. I'll try building node-usb under MacOS X first in the next weeks.

@TooTallNate

Ok, here's the output:

Nathan-Rajlichs-Mac-mini:node-usb nrajlich$ node-waf clean configure --debug=true build
'clean' finished successfully (0.015s)
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for program gcc or cc           : /usr/bin/gcc 
Checking for gcc                         : ok  
Checking for node path                   : ok /Users/nrajlich/.node_libraries 
Checking for node prefix                 : ok /usr/local 
Checking for libusb-1.0                  : yes 
Checking for library usb-1.0             : yes 
'configure' finished successfully (2.784s)
Waf: Entering directory `/Users/nrajlich/node-usb/build'
[1/6] cxx: src/node_usb.cc -> build/default/src/node_usb_1.o
[2/6] cxx: src/usb.cc -> build/default/src/usb_1.o
[3/6] cxx: src/device.cc -> build/default/src/device_1.o
[4/6] cxx: src/interface.cc -> build/default/src/interface_1.o
[5/6] cxx: src/endpoint.cc -> build/default/src/endpoint_1.o
[6/6] cxx_link: build/default/src/node_usb_1.o build/default/src/usb_1.o build/default/src/device_1.o build/default/src/interface_1.o build/default/src/endpoint_1.o -> build/default/usb_bindings.node
ld: warning: directory '/lib' following -L not found
Waf: Leaving directory `/Users/nrajlich/node-usb/build'
'build' finished successfully (3.962s)

Nathan-Rajlichs-Mac-mini:node-usb nrajlich$ node tests/node-usb-test.js
node-usb [../src/node_usb.cc:init() 23]: Initalizing NodeUsb
node-usb [../src/node_usb.cc:InitalizeAll() 8]: Entering
node-usb [../src/usb.cc:Initalize() 9]: Entering
node-usb [../src/usb.cc:Initalize() 87]: Leave
node-usb [../src/device.cc:Initalize() 15]: Entering...
node-usb [../src/device.cc:Initalize() 40]: Leave
node-usb [../src/interface.cc:Initalize() 20]: Entering...
node-usb [../src/interface.cc:Initalize() 41]: Leave
node-usb [../src/endpoint.cc:Initalize() 25]: Entering...
node-usb [../src/endpoint.cc:Initalize() 47]: Leave
node-usb [../src/usb.cc:GetDeviceList() 179]: Discover device list
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
Segmentation fault
@schakko
Owner

Uhm... Would you please replace the method Device::GetConfigDescriptor in src/device.cc with https://gist.github.com/707979 and recompile it. I hope the gist does not have any syntax errors - I'm currently not in the near of any development environment to check it.

@TooTallNate

No syntax errors :)

But it still segfaults. It gets a few steps further in the script though:

Nathan-Rajlichs-Mac-mini:node-usb nrajlich$ node tests/node-usb-test.js
node-usb [../src/node_usb.cc:init() 23]: Initalizing NodeUsb
node-usb [../src/node_usb.cc:InitalizeAll() 8]: Entering
node-usb [../src/usb.cc:Initalize() 9]: Entering
node-usb [../src/usb.cc:Initalize() 87]: Leave
node-usb [../src/device.cc:Initalize() 15]: Entering...
node-usb [../src/device.cc:Initalize() 40]: Leave
node-usb [../src/interface.cc:Initalize() 20]: Entering...
node-usb [../src/interface.cc:Initalize() 41]: Leave
node-usb [../src/endpoint.cc:Initalize() 25]: Entering...
node-usb [../src/endpoint.cc:Initalize() 47]: Leave
node-usb [../src/usb.cc:GetDeviceList() 179]: Discover device list
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 55]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
casting external argument
unwrapping self
get config descriptors
Segmentation fault
@schakko
Owner

That's some sort of mysterious. It could be a sort of this issue: http://libusb.6.n5.nabble.com/Darwin-get-configuration-td7077.html

Please do an

  #include assert.h 

on top of device.cc and an

  assert((device != NULL));

BEFORE line

  CHECK_USB(libusb_get_active_config_descriptor(self->device, &(self->config_descriptor)), scope)

and recompile it.

@schakko
Owner

Second try. Please pull the latest version from the repo and recompile it (without changes is the comment before).

@TooTallNate

Still a no-go for me:

Nathan-Rajlichs-Mac-mini:node-usb nrajlich$ node tests/node-usb-test.js
node-usb [../src/node_usb.cc:init() 23]: Initalizing NodeUsb
node-usb [../src/node_usb.cc:InitalizeAll() 8]: Entering
node-usb [../src/usb.cc:Initalize() 9]: Entering
node-usb [../src/usb.cc:Initalize() 87]: Leave
node-usb [../src/device.cc:Initalize() 15]: Entering...
node-usb [../src/device.cc:Initalize() 40]: Leave
node-usb [../src/interface.cc:Initalize() 20]: Entering...
node-usb [../src/interface.cc:Initalize() 41]: Leave
node-usb [../src/endpoint.cc:Initalize() 25]: Entering...
node-usb [../src/endpoint.cc:Initalize() 47]: Leave
node-usb [../src/usb.cc:GetDeviceList() 179]: Discover device list
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
node-usb [../src/device.cc:New() 57]: New Device object created
node-usb [../src/device.cc:Device() 44]: Assigning libusb_device structure to self
Segmentation fault
@schakko
Owner

http://pastebin.com/dWyAddfh

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x0000000100bf0e38 in get_configuration_index inlined at /private/tmp/libusb/libusb/os/darwin_usb.c:370
370 kresult = (*(priv->device))->GetNumberOfConfigurations (priv->device, &numConfig);
(gdb) bt
#0 0x0000000100bf0e38 in get_configuration_index inlined at /private/tmp/libusb/libusb/os/darwin_usb.c:370
#1 0x0000000100bf0e38 in darwin_get_active_config_descriptor (dev=0x1008107e0, buffer=0x7fff5fbfe7b0 "\001\a\005\004", len=8, host_endian=0x7fff5fbfe7ac) at os/darwin_usb.c:392
#2 0x0000000100bec6ba in libusb_get_active_config_descriptor (dev=0x1008107e0, config=0x10080e898) at descriptor.c:392
#3 0x0000000100bcbbac in NodeUsb::Device::GetConfigDescriptor (args=@0x7fff5fbfed50) at ../src/device.cc:392
#4 0x000000010007dedf in v8::internal::Builtin_HandleApiCall ()
Previous frame inner to this frame (gdb could not unwind past this frame)

On Darwin, every USB device has to be opened before using.
Will fix it in the next days.

@isaacs

So you figured out the issue and are going to fix it? Or do you still want me to try with the latest libusb code?

@schakko
Owner

Hey isaacs, had to do some study-related work the last days.
I (hopefully) fixed the issue in my development branch and will commit it in a few days.

@geuis

I'm trying to get node-usb running on Mac OS (snow leopard) too, but still running into the segmentation fault during 'make'

@xtian

Getting the segfault as well on Snow Leopard using libusb from http://git.libusb.org/?p=libusb.git

054-126:node-usb christian$ node tests/node-usb-test.js
node-usb [../src/node_usb.cc:init() 23]: Initalizing NodeUsb
node-usb [../src/node_usb.cc:InitalizeAll() 8]: Entering
node-usb [../src/usb.cc:Initalize() 9]: Entering
node-usb [../src/usb.cc:Initalize() 88]: Leave
node-usb [../src/device.cc:Initalize() 15]: Entering...
node-usb [../src/device.cc:Initalize() 45]: Leave
node-usb [../src/interface.cc:Initalize() 22]: Entering...
node-usb [../src/interface.cc:Initalize() 52]: Leave
node-usb [../src/endpoint.cc:Initalize() 24]: Entering...
node-usb [../src/endpoint.cc:Initalize() 52]: Leave
node-usb [../src/usb.cc:GetDeviceList() 200]: Discover device list
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:New() 65]: New Device object created
node-usb [../src/device.cc:GetConfigDescriptor() 198]: Open device handle for getConfigDescriptor (Darwin fix)
node-usb [../src/device.cc:GetConfigDescriptor() 201]: Get active config descriptor
Segmentation fault
@schakko
Owner

A while ago I talked to the libusb-developers. It seems to be a bug in libusb on MacOS. Because I do not own a MacOS X system (VirtualBox doesn't work) I can not further investigate this bug. It would be nice if anyone could look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.