Skip to content

Conversation

@bl4kraven
Copy link
Contributor

Hi

I'm using micropython unix port with bluetooth nimble enabled. When i'm run bluetooth example ble_simple_central.py, it exit with illegal instruction crash fault.

I found the bug is case by pthread_join in mp_bluetooth_hci_uart_deinit function.

The pthread_join says:

The behavior is undefined if the value specified by the thread argument to pthread_join() does not refer to a joinable thread.

If the thread is set detached attribute, and the thread is not joinable.

So i remove the thread detached attribute and fix the crash fault.

@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.42%. Comparing base (55e75c4) to head (b4b4d16).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12036   +/-   ##
=======================================
  Coverage   98.42%   98.42%           
=======================================
  Files         161      161           
  Lines       21253    21253           
=======================================
  Hits        20919    20919           
  Misses        334      334           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

bl4kraven and others added 2 commits July 17, 2024 15:01
A detached thread is not joinable, and the behavior maybe undefined.

Signed-off-by: Leo Chung <gewalalb@gmail.com>
As in the previous commit, the thread is later joined so can't be detached.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the fix_thread_detached_bug branch from bf519f6 to b4b4d16 Compare July 17, 2024 05:05
@dpgeorge
Copy link
Member

Thanks for the fix. This looks correct, although I did not test it.

I've also made a follow-up commit to fix the same thing in pmbtstackport_usb.c.

@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@dpgeorge dpgeorge merged commit b4b4d16 into micropython:master Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants