System lockup when using chvprintf()
Posted: Mon Sep 29, 2014 7:38 pm
I have a situation in which my app, which uses the synchronous message mechanism, stops executing after some time (hours). In an effort to narrow down the source of the problem (my debugging is limited to printf()), I commented out some code. As long as I don't log anything (for which I use chvprintf()), it seems to run indefinitely (going on 10 hours now).
Here's the setup: Everything is statically allocated. I have a thread that blinks an LED (which is how I can tell it locked up). I have a "main" thread. There are two more threads, a "GPSBroker" and a "GPSReader". The reader loops reading bytes from the serial port to which the GPS is attached. It parses the packets and the messages the GPSBroker to update the broker's state (which is just a handful of GPS parameters). The main thread messages the broker periodically to get the current GPS state. The main thread loops, doing some synchronous reads of other I/O (a SPI port), some ADC reads, writing to another serial port, and logging via chvprintf(). Everything else is fine, but if I leave in the chvprintf() calls, it locks up after 30 minutes to a couple hours.
One note: I added a mutex around my chvprintf() call (code here: https://pastee.org/v264r) because sometimes I get characters interleaved. This didn't seem to make any difference in the behavior (it locked up before and after I added the mutex). Floating point conversions are enabled. The stack should be big enough (I don't think chvprintf() would suddenly need more stack for the same set of strings).
I find it hard to believe chvprintf() would be responsible for this, but experiments suggest it is. Any ideas? Thanks!
Here's the setup: Everything is statically allocated. I have a thread that blinks an LED (which is how I can tell it locked up). I have a "main" thread. There are two more threads, a "GPSBroker" and a "GPSReader". The reader loops reading bytes from the serial port to which the GPS is attached. It parses the packets and the messages the GPSBroker to update the broker's state (which is just a handful of GPS parameters). The main thread messages the broker periodically to get the current GPS state. The main thread loops, doing some synchronous reads of other I/O (a SPI port), some ADC reads, writing to another serial port, and logging via chvprintf(). Everything else is fine, but if I leave in the chvprintf() calls, it locks up after 30 minutes to a couple hours.
One note: I added a mutex around my chvprintf() call (code here: https://pastee.org/v264r) because sometimes I get characters interleaved. This didn't seem to make any difference in the behavior (it locked up before and after I added the mutex). Floating point conversions are enabled. The stack should be big enough (I don't think chvprintf() would suddenly need more stack for the same set of strings).
I find it hard to believe chvprintf() would be responsible for this, but experiments suggest it is. Any ideas? Thanks!