Giter VIP home page Giter VIP logo

Comments (21)

schakko avatar schakko commented on August 13, 2024

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

from node-usb.

isaacs avatar isaacs commented on August 13, 2024

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

from node-usb.

schakko avatar schakko commented on August 13, 2024

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 ?

from node-usb.

isaacs avatar isaacs commented on August 13, 2024

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.

from node-usb.

schakko avatar schakko commented on August 13, 2024

Please try the latest commit.

from node-usb.

TooTallNate avatar TooTallNate commented on August 13, 2024

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.

from node-usb.

rhiokim avatar rhiokim commented on August 13, 2024

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

from node-usb.

TooTallNate avatar TooTallNate commented on August 13, 2024

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.

from node-usb.

schakko avatar schakko commented on August 13, 2024

@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.

from node-usb.

TooTallNate avatar TooTallNate commented on August 13, 2024

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

from node-usb.

schakko avatar schakko commented on August 13, 2024

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.

from node-usb.

TooTallNate avatar TooTallNate commented on August 13, 2024

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

from node-usb.

schakko avatar schakko commented on August 13, 2024

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.

from node-usb.

schakko avatar schakko commented on August 13, 2024

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

from node-usb.

TooTallNate avatar TooTallNate commented on August 13, 2024

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

from node-usb.

schakko avatar schakko commented on August 13, 2024

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.

from node-usb.

isaacs avatar isaacs commented on August 13, 2024

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?

from node-usb.

schakko avatar schakko commented on August 13, 2024

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.

from node-usb.

geuis avatar geuis commented on August 13, 2024

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

from node-usb.

xtian avatar xtian commented on August 13, 2024

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

from node-usb.

schakko avatar schakko commented on August 13, 2024

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.

from node-usb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.