node-usb
                                
                                 node-usb copied to clipboard
                                
                                    node-usb copied to clipboard
                            
                            
                            
                        segfault on make
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 ()
Seems to be a problem with MacOS X port libusb. Are you using libusb-1.0?
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
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 ?
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.
Please try the latest commit.
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.
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
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.
@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.
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
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.
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
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.
Second try. Please pull the latest version from the repo and recompile it (without changes is the comment before).
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
http://pastebin.com/dWyAddfh
On Darwin, every USB device has to be opened before using. Will fix it in the next days.
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?
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.
I'm trying to get node-usb running on Mac OS (snow leopard) too, but still running into the segmentation fault during 'make'
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
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.