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

Hang on "starting sensor threads" #1

Open
cbosoft opened this issue May 25, 2020 · 2 comments
Open

Hang on "starting sensor threads" #1

cbosoft opened this issue May 25, 2020 · 2 comments
Assignees

Comments

@cbosoft
Copy link
Owner

cbosoft commented May 25, 2020

Running valgrind on the exe causes it to hang setting up sensor threads.

@cbosoft cbosoft self-assigned this May 25, 2020
@cbosoft
Copy link
Owner Author

cbosoft commented May 26, 2020

Seems to be caused by a call to glob() with flags GLOB_NOSORT when there are no matches. Instead of returning with error, it keeps going. Adding GLOB_ERR to the flags stops the hang, but this may not be the desired behaviour.

Nevermind, seems to be a timing issue between threads. Valgrind changes the way memory is accessed and perhaps this is in causing issues with the threads. Unfortunately this limites the effectiveness of using valgrind to source memoery errors! This wasn't always the case, I wonder if I've done something wrong somewhere...

@cbosoft
Copy link
Owner Author

cbosoft commented May 26, 2020

Valgrind seems to force a program to run in single thread[1,2], and so my waits were affecting the flow of the program and causing it to halt when the wait didn't release control to the thread it was waiting on.

These waits are in the main thread waiting on the status of a sensor thread to come to a ready state (set by flag in a common struct). I spinlock the main thread while (!var) usleep(100);. However, usleep is non-blocking and so this issue should not arise.

Valgrind's drd looks like a promising tool to debug this issue.

  1. https://stackoverflow.com/a/10149626/10042036
  2. https://stackoverflow.com/questions/8663148/valgrind-stalls-in-multithreaded-socket-program

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

1 participant