coobjc icon indicating copy to clipboard operation
coobjc copied to clipboard

调用函数 void coroutine_resume_im(coroutine_t *co) 时,没有保证 coroutine_t 的状态为 Ready 或 Suspend

Open jieliangma opened this issue 5 years ago • 5 comments

堆栈 image

推测崩溃的代码行:coroutine.m:237

jieliangma avatar May 29 '19 03:05 jieliangma

协程的block是有重入吗?理论上正常使用不应该进入这里

NianJi avatar Jun 05 '19 11:06 NianJi

I am getting these same crashes in crash logs from the app I recently added coswift to.

Crashed: com.apple.root.default-qos
SIGABRT ABORT 0x0000000183a0fd88
Crashed: com.apple.root.default-qos
0  libsystem_kernel.dylib         0x183a0fd88 __pthread_kill + 8
1  libsystem_pthread.dylib        0x1839281e8 pthread_kill$VARIANT$mp + 136
2  libsystem_c.dylib              0x18387b934 abort + 100
3  libsystem_c.dylib              0x18387ad54 err + 286
4  cocore                         0x103d749b4 coroutine_resume_im + 348
5  cocore                         0x103d74790 coroutine_scheduler_main + 76
6  cocore                         0x103d74ae8 coroutine_main + 32

The crash is on the assert at the bottom of the function, indicating the coroutine status is neither ready nor suspended.

My usage is fairly straightforward, launching a single coroutine with several async functions using a channel to suspend the coroutine while performing some database I/O.

I will swap the channels out to use promises instead and note if the crashes continue afterwards.

jeffdgr8 avatar Jun 08 '20 22:06 jeffdgr8

After changing the Chans to Promises, the crash continues. So this isn't specifically caused by one or the other.

jeffdgr8 avatar Jun 10 '20 18:06 jeffdgr8

Could you provide the demo code?

NianJi avatar Jun 11 '20 06:06 NianJi

This seems to be resolved with a change I made to ensure canceling an active coroutine before dismissing a view controller.

jeffdgr8 avatar Jul 14 '20 19:07 jeffdgr8