alibaba / coobjc

coobjc provides coroutine support for Objective-C and Swift. We added await method、generator and actor model like C#、Javascript and Kotlin. For convenience, we added coroutine categories for some Foundation and UIKit API in cokit framework like NSFileManager, JSON, NSData, UIImage etc. We also add tuple support in coobjc.
https://github.com/alibaba/coobjc
Apache License 2.0
4.03k stars 525 forks source link

Get an empty array when calling [NSThread callStackReturnAddresses] #86

Closed Magic-Unique closed 5 years ago

Magic-Unique commented 5 years ago

Context and Description

co_launch(^{
    id result = [COPromise promise:^(COPromiseFulfill fullfill, COPromiseReject reject) {
           fullfill([NSThread callStackReturnAddresses]);
    }];
   NSLog(@"%@", result); // Get @[]
});

Environment Details

Expected behavior

Get the real call stack list.

Actual behavior

Get an empty array.

Steps to Reproduce

Copy the code to reproduce

method call stacks

NianJi commented 5 years ago

Since coobjc is stackful coroutine, we create a new stack run the coroutine's code. which make the backtrace() can't return succes, you can use co_backtrace instead.