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

"Open()" in Python wrapper resulting in "Segmentation fault" #113

Closed
Forage opened this Issue Jul 14, 2015 · 15 comments

Comments

Projects
None yet
4 participants
@Forage
Copy link

Forage commented Jul 14, 2015

Libcec, the Python wrapper in particular, is having issues since build #0703 of OpenElec (@MilhouseVH build).
Since #0703 "self.lib.Open()" give me a "Segmentation fault" (line 80 in /usr/bin/pyCecClient.py) when trying to open a connection to a USB-CEC adapter on a RPi.

This build included quite a few libcec updates, as you can see in the post above, but I can't spot an obvious one resulting in this issue. Do you have an idea which one could be the cause of the problem or is there any way to get some more debug info to narrow it down?

@MilhouseVH

This comment has been minimized.

Copy link

MilhouseVH commented Jul 14, 2015

Is this a Kodi segfault, if so you should have a crash log.

If it's some other non-Kodi process that is faulting try enabling core dumping (ulimit -c unlimited) then once you have a core, try running it through gdb (gdb /path/to/your/executable --core="<your core>" --batch -ex "thread apply all bt" 2>/dev/null)

@opdenkamp

This comment has been minimized.

Copy link
Contributor

opdenkamp commented Jul 14, 2015

i haven't tested if this displays a proper message and exits correctly if a second program tries to open a connection, but i think that's what happening here. Kodi will be having an open connection to the adapter here, and then the second instance (python) will fail.

you'll have to disable CEC in Kodi for this to work.

but still, I'd like to see a stack trace of this so it can complain without crashing. thanks

@Forage

This comment has been minimized.

Copy link
Author

Forage commented Jul 14, 2015

It happens when I run e.g. "python /usr/bin/pyCecClient.py" in through ssh and it's just the script breaking so I don't think this qualifies as a Kodi segfault.

It's not a problem of a second connection being opened to an adapter with an existing connection. Kodi had one open with the RPi CEC adapter. I'm connecting to an attached USB-CEC adapter (/dev/ttyACM0) which is disabled in the Kodi settings.
This has worked without issues until the update I referred to.

Does the method described by MilhouseVH provide the desired stack trace? I'll give that a go tomorrow if needed.

For what it's worth: if I do steal Kodi's connection to the RPi's adapter on purpose then I didn't get a segfault in the past either. Kodi looses it's connection but python is using it happily from there on. I'll check if this is still the case after the update tomorrow as well.

@MilhouseVH

This comment has been minimized.

Copy link

MilhouseVH commented Jul 14, 2015

Does the method described by MilhouseVH provide the desired stack trace? I'll give that a go tomorrow if needed.

Yes. If you run:

ulimit -c unlimited
python /usr/bin/pyCecClient.py

you should end up with a core dump in /storage/.cache/cores once the process has seg faulted, eg.

-rw-------    1 root     root      63127552 Jul 14 23:35 core.!usr!bin!python2.7.1436913318.8747

Your filename will be similar, but different.

Then use gdb to print the stacktrace::

gdb python --core=/storage/.cache/cores/core.!usr!bin!python2.7.1436913318.8747 --batch -ex "thread apply all bt"

should get you a stacktrace - not sure how useful the stacktraces will be as you're not using a debug build, but it's better than nothing (if you need a debug build, let me know - your FAT partition will need to be at least 384MB to use a debug build).

By the way, /usr/bin/pyCecClient.py isn't crashing for me (tested on both Pi1 and Pi2) with build #0714, but then I don't use CEC (it's disabled in Kodi), or have any additional USB CEC dongles connected (does it still crash with the dongle unplugged?)

@opdenkamp

This comment has been minimized.

Copy link
Contributor

opdenkamp commented Jul 14, 2015

it may be a bug in the detection code. stack trace will tell. never tested it with both the pi's internal wire and a usb-cec either ;-)

@Forage

This comment has been minimized.

Copy link
Author

Forage commented Jul 15, 2015

Here's the output of the gdb command: http://pastebin.com/nSgw58ns
Let met know if it's useful this way or if you need any more information.

When I disconnect the USB-CEC adapter then the same pyCecClient.py script will happily connect to the RPi's CEC adapter.

P.s. does ulimit -c unlimited need to be undone or is it not persistent?

@MilhouseVH

This comment has been minimized.

Copy link

MilhouseVH commented Jul 15, 2015

P.s. does ulimit -c unlimited need to be undone or is it not persistent?

It's not persistent and only applies to that ssh session.

@opdenkamp

This comment has been minimized.

Copy link
Contributor

opdenkamp commented Jul 19, 2015

it's a bug in 2ac430f

@Forage

This comment has been minimized.

Copy link
Author

Forage commented Jul 30, 2015

I bet it's not the typo in line 49 of src/libcec/platform/drm/drm-edid.cpp ;-P

@ghost

This comment has been minimized.

Copy link

ghost commented Sep 1, 2015

opendir() returns NULL if the directory doesn't exist.
This should fix it:
https://clbin.com/sEYl5

@MilhouseVH

This comment has been minimized.

Copy link

MilhouseVH commented Sep 2, 2015

@Forage: I have included @anaconda's patch in the latest #0901 test build - perhaps you can give it a try and report?

@Forage

This comment has been minimized.

Copy link
Author

Forage commented Sep 2, 2015

@MilhouseVH thanks for including it to be able to take it for a spin.
@anaconda your fix works like a charm! Thank you!

@opdenkamp

This comment has been minimized.

Copy link
Contributor

opdenkamp commented Sep 25, 2015

@anaconda could you create a PR from that patch please, and sign the dev agreement, then we can include it: http://www.pulse-eight.net/contributors

thanks!

@ghost

This comment has been minimized.

Copy link

ghost commented Sep 25, 2015

It seems you've merged a similar fix in #133, so this can be closed.

@opdenkamp

This comment has been minimized.

Copy link
Contributor

opdenkamp commented Sep 25, 2015

yeah sorry, same bug got fixed in there ;-)

@opdenkamp opdenkamp closed this Sep 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.