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 on macOS #27

Open
aadevmobile opened this issue Mar 16, 2020 · 11 comments
Open

Segmentation fault on macOS #27

aadevmobile opened this issue Mar 16, 2020 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@aadevmobile
Copy link

aadevmobile commented Mar 16, 2020

Hello,
When running the pepper_basic or any other test it loads the model and crashes..
I'm not sure why. If I run a pybullet test it works.

AA-MacBook-Pro:peppersim aa$ python peper_basic.py
pybullet build time: Mar 10 2020 14:41:15
Version = 4.1 INTEL-14.2.16
Vendor = Intel Inc.
Renderer = Intel(R) Iris(TM) Plus Graphics 650
b3Printf: Selected demo: Physics Server
startThreads creating 1 threads.
starting thread 0
started thread 0
MotionThreadFunc thread started
Fatal Python error: Segmentation fault

Current thread 0x000070000eccd000 (most recent call first):
File "/Users/aa/Library/Python/2.7/lib/python/site-packages/qibullet/camera.py", line 265 in _getCameraImage
File "/Users/aa/Library/Python/2.7/lib/python/site-packages/qibullet/camera.py", line 386 in _frameExtractionLoop
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754 in run
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801 in __bootstrap_inner
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 774 in __bootstrap

Thread 0x0000000103c45dc0 (most recent call first):
File "/Users/aa/Library/Python/2.7/lib/python/site-packages/qibullet/camera.py", line 152 in getFrame
File "/Users/aa/Library/Python/2.7/lib/python/site-packages/qibullet/camera.py", line 304 in _waitForCorrectImageFormat
File "/Users/aa/Library/Python/2.7/lib/python/site-packages/qibullet/camera.py", line 365 in subscribe
File "/Users/aa/Library/Python/2.7/lib/python/site-packages/qibullet/robot_virtual.py", line 205 in subscribeCamera
File "peper_basic.py", line 23 in main
File "peper_basic.py", line 32 in
Segmentation fault: 11

@aadevmobile aadevmobile changed the title Hello, Segmentation fault: 11 Mar 16, 2020
@mbusy mbusy self-assigned this Mar 16, 2020
@mbusy mbusy added the bug Something isn't working label Mar 16, 2020
@mbusy
Copy link
Member

mbusy commented Mar 16, 2020

Hi,
Thanks for reporting the issue. Could you specify which version of qiBullet you're currently using, and your OS version ?

Edit: Looking at your logs, my guess is that the combination Mac OS + default camera renderer issues the segfault. Could you run the following script and tell me if it works ? (If it doesn't work, try replacing gui=True by gui=False)

from qibullet import SimulationManager
from qibullet import PepperVirtual


def main():
    simulation_manager = SimulationManager()
    client = simulation_manager.launchSimulation(gui=True)
    pepper = simulation_manager.spawnPepper(client, spawn_ground_plane=True)
    raw_input("Press enter to stop the simulation")
    simulation_manager.stopSimulation(client)

if __name__ == "__main__":
    main()

@aadevmobile
Copy link
Author

Hi mbusy,

thank you very much for your fast reply

  • macOs Catalina 10.15.1
  • qibullet 1.4.0 - numpy 1.16.6 - pybullet 2.6.6

With the sample you provided it doesn't crash but it stops responding within the window; I'm able to press enter in the terminal to exit it. Without the gui = False it seems to run ok.

what are the minimum requirements to run it? I mean could it be that my mac specs can't handle it?

@mbusy
Copy link
Member

mbusy commented Mar 16, 2020

You're welcome. I don't think that your specs are the problem, I believe that the OS doesn't handle OpenGL3 successfully... The way I see it you've got 2 problems:

  • The GUI doesn't respond
  • A seg fault appears when retrieving camera images

Regarding the first issue, one possible solution would be to replace that line by

pybullet.connect(pybullet.GUI, options="--opengl2")

Regarding the second issue, I'm guessing that using pybullet.ER_TINY_RENDERER instead of pybullet.ER_BULLET_HARDWARE_OPENGL (here) might fix the issue, but that's not ideal.

I'll test this as soon as possible, but I don't have a system running Mac OS at my disposal (and with the COVID situation I might have some troubles getting my hands on one). I'll eventually test that on a VM

@aadevmobile
Copy link
Author

Hi mbusy,

  • when adding the opengl2 option, GUI doesn't start at all.
  • changing it to ER_TINY_RENDERER I still get the Segmentation fault: 11
    same as before :/

@mbusy
Copy link
Member

mbusy commented Mar 17, 2020

Alright, it was worth a shot, thanks for testing 😄.

Another explanation for the first problem could be the simulation step thread. On Windows / Linux, running a simulation with a GUI will automatically spawn an additional thread, stepping the simulation. If I remember correctly, in Mac OS that thread might not be spawned because of OS limitations... So we would need to manually spawn such a thread. Could be done by connecting to a pybullet GUI_SERVER, and then connecting to the created server using pybullet.connect(pybullet.SHARED_MEMORY)

@mbusy
Copy link
Member

mbusy commented Mar 17, 2020

This comment (issue in bullet3) seems to confirm it. I just hope that a Python thread will work, instead of a big while loop

@mbusy mbusy changed the title Segmentation fault: 11 Segmentation fault on macOS Apr 12, 2020
@lubiluk
Copy link
Contributor

lubiluk commented Nov 10, 2020

Hi, I'm also experiencing crashes on MacOS and I'm pretty sure it's related to camera. Without camera use everything seems to work well. For instance this works (https://github.com/softbankrobotics-research/qibullet/blob/master/examples/robot_joint_control.py) while this doesn't (https://github.com/softbankrobotics-research/qibullet/blob/master/examples/pepper_basic.py).

The line that makes everything crash is:
handle = pepper.subscribeCamera(PepperVirtual.ID_CAMERA_TOP)

I hope it helps with investigation...

@mbusy
Copy link
Member

mbusy commented Nov 10, 2020

Thanks for the feedback @lubiluk, yes the camera is indeed a source of bug on macOS, even when using ER_TINY_RENDERER over ER_BULLET_HARDWARE_OPENGL (see previous comment)...

There is also the problem of the freezing GUI: when you run the robot_joint_control example, do you manage to "nudge" (for lack of a better word) the head (or any link) of the robot, by clicking and dragging it with your mouse ?

@lubiluk
Copy link
Contributor

lubiluk commented Nov 10, 2020

There is also the problem of the freezing GUI: when you run the robot_joint_control example, do you manage to "nudge" (for lack of a better word) the head (or any link) of the robot, by clicking and dragging it with your mouse ?

Nudging the the robot seems alright. It doesn't freeze on my machine:

Version = 4.1 ATI-3.10.18
Vendor = ATI Technologies Inc.
Renderer = AMD Radeon R9 M370X OpenGL Engine

@elggem
Copy link

elggem commented Dec 14, 2020

Hi, I looked a bit into this problem and found the following:

There is two crashes happening in the _getCameraImage function, one for pybullet.getLinkState and one for pybullet.getCameraImage.

When I replace the first call to pybullet.getLinkState and assign zero vectors to pos_world and q_world it works until the call to pybullet.getCameraImage but then segfaults. Changing the renderer to ER_TINY_RENDERER does not help even in that case the program segfaults.

I dont know how else to proceed to investigate this, but maybe it is helpful to somebody.

@mbusy
Copy link
Member

mbusy commented Dec 16, 2020

@elggem Thanks for the info, even though I don't have a lot of time to work on this issue it's always appreciated. The fact that either renderer causes a segfault was already known, but I wasn't aware that pybullet.getLinkState also causes a crash, thanks for reporting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants