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

tempered_close( device ) segfaults #14

Open
pgrandin opened this issue Feb 7, 2013 · 1 comment
Open

tempered_close( device ) segfaults #14

pgrandin opened this issue Feb 7, 2013 · 1 comment

Comments

@pgrandin
Copy link

pgrandin commented Feb 7, 2013

Hi,

I just received a TEMPerV1.2 device and started toying with it.
First thing I tried was to write a simple script to get the temperature using read-all, then update an rrd using a shell script. It worked nicely, so I started hacking my own C program to do both (get the info and update the rrd) from the same program (until adding more features).

As soon as I started accessing the device using my own code (which is basically a rip off read-all.c) my other script (which was running from crontab) stopped working (read-all reporting "No devices were found.").

Now my own code segfaults when trying to " tempered_close( device );"

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd8588 in tempered_close () from /usr/local/lib64/libtempered.so.0

I can read the temperature and update the rrd from my own program, it works, but it segfault when trying to close the device.

Do you have any idea of what can be wrong?

Could it be some kind of race condition between running my own program and running the script from the crontab at the same time?

Thanks in advance for your help, and thanks a lot for this very useful library.

@edorfaus
Copy link
Owner

edorfaus commented Aug 3, 2013

I'm pretty sure that only one program at a time can have the device open to talk with it, so it's not surprising that the cron script can't read the temperature while your own program is running - but if it still fails after your program has exited, there's something else going on. Even if the segfault means we don't close the device properly, the kernel should still close it for us when the program exits. I guess you could run into problems if your program uses the libusb version of HIDAPI while the cron script uses the hidraw version, as libusb disconnects the device from the kernel's HID driver.

The segfault is odd, as I haven't seen any myself - could your post some code that reproduces the problem?

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

2 participants