-
Notifications
You must be signed in to change notification settings - Fork 98
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 Python3 #20
Comments
Hi Corteil, thanks! |
@richlegrand @Corteil I dug into the code for this and libusb init looks fine. I had a hunch that SWIG is not configured to generate an exception wrapper for the init. I suggested to Brian on twitter to remove the change_prog() line and see if the Seg Fault goes away, on the hunch that it is (incorrectly) trying to access a driver that was not initialised after it found no hardware or the hardware was locked and therefore a context and handle for it could not be obtained in the C lib. Due to lack of state checks in the change_prog() C function this would cause access to an invalid memory location (via a zero context variable, effectively NULL). Brian removed the last line and the SIGSEGV doesn't happen, as I predicted. The user fix is therefore to check the return result from pixy.init() and if it is non zero, the hardware is locked or not present. His user program can then take evasive action. The library fix here is either (a) change the SWIG configuration to generate an exception wrapper for the init() call and throw an exception if the return result is non zero, or Twitter chat is here: https://twitter.com/whaleygeek/status/1232384123840475139?s=20 Hope this helps. |
@richlegrand You might want to consider hosting this on pypi.org and configuring a wheel for this, so that host users can pip install it without needing to build all the code. (The wheels will pre-compile for all configured platforms for you, so users don't have to build it themselves. Wheels are documented here: https://pythonwheels.com/ There is also a PiWheels project now, as your package will be a popular thing on RaspberryPi especially with the PiWars robotics competition, and this would allow Raspberry Pi users to just pip install the package and get the libs ready-built. |
Ah, thank you Brian. That is very helpful! |
Is this still an existing issue? |
I'm trying to trap a 'Segmentation fault' when the Pixy Camera is not connected or being used by another program. 'Segmentation fault' is printed to the command line and program is exited. The program is in Python3.
fails at line 4, if another program or PixyMon is running.
The text was updated successfully, but these errors were encountered: