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

fix: random crash when starting or reloading #394

Merged
merged 7 commits into from
Dec 18, 2023
Merged

fix: random crash when starting or reloading #394

merged 7 commits into from
Dec 18, 2023

Conversation

dunglas
Copy link
Owner

@dunglas dunglas commented Dec 16, 2023

Ugly fix for crashes reported in laravel/octane#764.

test-reload.sh is a reproducer. The crash produces the following stack trace (collected using lldb on Mac):

* thread #192, stop reason = EXC_BREAKPOINT (code=1, subcode=0x18d6df21c)
    frame #0: 0x000000018d6df21c libsystem_pthread.dylib`_pthread_mutex_firstfit_wake + 96
libsystem_pthread.dylib`:
->  0x18d6df21c <+96>: brk    #0x1

libsystem_pthread.dylib`:
    0x18d6df220 <+0>:  pacibsp 
    0x18d6df224 <+4>:  stp    x29, x30, [sp, #-0x10]!
    0x18d6df228 <+8>:  mov    x29, sp
Target 0: (frankenphp) stopped.
(lldb) bt
* thread #192, stop reason = EXC_BREAKPOINT (code=1, subcode=0x18d6df21c)
  * frame #0: 0x000000018d6df21c libsystem_pthread.dylib`_pthread_mutex_firstfit_wake + 96
    frame #1: 0x000000018d6dcdb4 libsystem_pthread.dylib`_pthread_mutex_firstfit_unlock_slow + 244
    frame #2: 0x0000000101232510 frankenphp`thpool_add_work + 184
    frame #3: 0x0000000101233984 frankenphp`manager_thread + 116
    frame #4: 0x000000018d6e2034 libsystem_pthread.dylib`_pthread_start + 136

It looks like there is a race condition during the startup of https://github.com/Pithikos/C-Thread-Pool, this sleep is a workaround to be sure that threads are ready before sending them work.

A better fix should be possible, but I don't understand why the threads aren't ready while there is code in the library for that.

@dunglas dunglas merged commit 517e086 into main Dec 18, 2023
39 checks passed
@dunglas dunglas deleted the fix/crashes branch December 18, 2023 08:08
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

Successfully merging this pull request may close these issues.

1 participant