EmergeTools / ETTrace

Easily and accurately profile iOS apps
https://www.emergetools.com/ettrace
MIT License
567 stars 23 forks source link

Non-reentrant functions used after thread suspend #96

Closed noahsmartin closed 1 month ago

noahsmartin commented 1 month ago

In the Swift version of Tracer, which is not used in production yet, there are some calls to functions that are not async signal safe like dladdr as well as heap allocations. The function getCallStack should be reentrant to avoid deadlocks: https://github.com/EmergeTools/ETTrace/blob/f791b54c68f62cbf5fa4b0253d91182c522c2c21/ETTrace/TracerSwift/ThreadHelper.swift#L82

The symbolication step should happen after threads are resumed, and we need to be careful not to allocate any memory on the heap while a thread is suspended, probably that portion of code should be in C since allocations can't be guaranteed to be avoided in Swift

michaeleisel commented 1 month ago

Would it make sense to merge this one with the C++ one?

noahsmartin commented 1 month ago

I think so - not exactly clear why the Swift one was added @Itaybre might know

Itaybre commented 1 month ago

This was created for Snapshots, since that project was already in Swift, I used that. Didn't realize it could add issues with the threads

noahsmartin commented 1 month ago

This is fixed by https://github.com/EmergeTools/ETTrace/pull/100