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 when calling start_ranging #37

Open
slishak opened this issue May 3, 2020 · 9 comments
Open

Segmentation fault when calling start_ranging #37

slishak opened this issue May 3, 2020 · 9 comments

Comments

@slishak
Copy link

slishak commented May 3, 2020

I have a brand new Pimoroni VL53L1X connected to the I2C bus on my Raspberry Pi 4B. Using this Python library, I get a segmentation fault when I start ranging:

Python 2.7.17 (default, Apr 15 2020, 17:20:14)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import VL53L1X
>>> tof = VL53L1X.VL53L1X()
>>> tof.open()
VL53L1X Start Ranging Address 0x29

VL53L0X_GetDeviceInfo:
Device Name : VL53L1 cut1.1
Device Type : VL53L1
Device ID :
ProductRevisionMajor : 1
ProductRevisionMinor : 11
>>> tof.start_ranging(1)
Segmentation fault

I've tried building from source and got the same error. Also the same on Ubuntu instead of Raspbian.

I thought I just had a dodgy sensor, but if I use the qwiic_vl53l1x library from SparkFun, everything works fine:

Python 2.7.17 (default, Apr 15 2020, 17:20:14)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import qwiic_vl53l1x
>>> tof = qwiic_vl53l1x.QwiicVL53L1X()
>>> tof.sensor_init()
>>> tof.set_distance_mode(1)
1
>>> tof.start_ranging()
>>> tof.get_distance()
190
>>> tof.stop_ranging()
@Gadgetoid
Copy link
Member

Sorry, I seem to have missed this- did you get any closer to figuring out what the problem might be?

I can only guess the device was responding in an unexpected way, such that it caused the library to crash, but I've no idea quite how.

@slishak
Copy link
Author

slishak commented Aug 4, 2020

This issue came from a lockdown project that I'm no longer working on as I'm back to work, so unfortunately don't really have the time to continue debugging now, sorry! In the end I just continued with the qwiic library instead; I assume the reason this library doesn't work for me is just a peculiarity with my device as nobody else seems to have the same issue.

If/when I do get back to this, what's the best way for me to debug the issue?

@edahle2022
Copy link

I'm having the same exact problem with the sensor on Ubuntu using Python. If anyone's figured out the solution, I'd appreciate it.

@eladpar-rnd
Copy link

having the same problem Rasberry pi 4 ubuntu 18.04

@eladpar-rnd
Copy link

after some debugging I've identified the problem.
the address allocated in the c file vl53l1x_python.c VL53L1_DEV * dev
cannot be accessed again in all functions of c file (_TOF_LIBRARY)
it doesn't matter what address i allocate memory (tried with int * ) after sending it to the python file and trying to accesses again with the c file gets a seg fault

@eladpar-rnd
Copy link

another comment:
turns out it happens in Python 2.7.15+ and Python 3.7.11 (that I checked)
but in Python 3.6.8 when pip installing it works fine

@dko1905
Copy link

dko1905 commented Oct 16, 2022

Same issue here with a Raspberry Pi 4 running Raspberry OS bullseye using Python 3.9.2 installed from source.

@sibujacob
Copy link

Hello,

Is there anyone who has recovered from this fault " segmentation fault (core dumped) " error while using this code on a RasPi 3b+ . i am currently using the ubuntu os on raspi

@Darth-Carrotpie
Copy link

Same fault.
Using RPI5

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

7 participants