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 violation when receiving #7

Open
bomm opened this issue Apr 1, 2021 · 1 comment
Open

segmentation violation when receiving #7

bomm opened this issue Apr 1, 2021 · 1 comment

Comments

@bomm
Copy link

bomm commented Apr 1, 2021

I noticed that sometimes the vhduino program reports a problem

2021-03-31 20:01:30 sigHandler: Unhandled signal 11, terminating

I'm using a Raspberry Pi 3B+ with Raspbian 10.9, libpigpio1 1.71-0~rpt1, kernel 5.4.72-v7+ and an RXB6 receiver connected to GPIO 17.

I was able to reproduce the problem when running vhduino in gdb. When I type a command RF receive 17 and step through the program, the signal occurs after stepping over the call to gpioSetAlertFunc() in rfcontrol_command_receive(). Unfortunately I was not able to get a useful stacktrace.

By analyzing the source code I found that rfcontrol_command_receive() calls gpioSetAlertFunc() to set handle_pigpio_interrupt() as a callback function and then calls RFControl::startReceiving which will assign an inner callback function handleInterrupt() to _hw_interruptCallback using hw_attachInterrupt().

If an interrupt occurs between gpioSetAlertFunc() and hw_attachInterrupt(), the function pointer _hw_interruptCallback can be NULL which can result in a segmentation fault when this function pointer is called.

When debugging, the time between gpioSetAlertFunc() and hw_attachInterrupt() is rather long and the problem occurs every time. When running the program in the normal way, the problematic time interval is short, so the problem doesn't seem to occur every time.

I'm preparing a fix.

bomm added a commit to bomm/virtualhomeduino that referenced this issue Apr 1, 2021
@mwittig
Copy link

mwittig commented Jun 19, 2021

I am very sorry for the delay in reply. Currently, the project is lacking maintainers and I have hardly no time due to work and private commitments. I am very grateful for your detailed problem analysis and PR. I'll look into this asap.

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