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

Race condition with semaphores ... manifesting in BLE libraries #731

Closed
nkolban opened this issue Oct 15, 2017 · 5 comments
Closed

Race condition with semaphores ... manifesting in BLE libraries #731

nkolban opened this issue Oct 15, 2017 · 5 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@nkolban
Copy link

nkolban commented Oct 15, 2017

We have been hunting a BLE library problem for a while which can be read about in great depth here:

nkolban/esp32-snippets#121

Through pure brute force, we narrowed it down to an adverse interaction between some combination of the following:

  1. The very latest toolchain with pthreads support
  2. The very latest ESP-IDF
  3. The very latest Arduino-ESP32
  4. Working with semaphores
  5. Only some boards

The problem does not appear to manifest in the same logic in ESP-IDF. See the above defect for all the history and conclusions made so far. In summary, at this point ... we have found that calling a FreeRTOS Semaphore release without following it with a 10msec delay causes one set of results and a crash while if we introduce a 10msec delay after the Semaphore release, all works. The errors manifest themselves in internals code rather than in user code.

A circumvention has been added to the BLE libraries to pause for 10msecs after releasing a semaphore. This isn't ideal but works. Ideally we can put our heads together and see if we can gain some additional insight into the puzzle. I am able to recreate on a board in my environment but only on one board (so far).

@tonu42
Copy link

tonu42 commented Oct 17, 2017

Just to chime in, getting the abort() error on my ESP32 Sparkfun Thing, no issue on ESPea32. Will test on ESP32 lite later.

@me-no-dev
Copy link
Member

How often do you release semaphores? 10ms is ages :)

@nkolban
Copy link
Author

nkolban commented Oct 17, 2017

Howdy ... ideally we don't want any delay. The delay as documented in this issue:

nkolban/esp32-snippets#121

is currently purely to get the user base working until we can resolve the puzzle properly to determine where the race condition is coming from. There is every likelihood that it is a BLE C++ code issue ... but my goal is to get it working for the community and then we can polish from there. As found in issue 121, it seems to be a good one occurring on only some boards and not others.

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

3 participants