cmyr / cargo-instruments

A cargo plugin to generate Xcode Instruments trace files
MIT License
672 stars 34 forks source link

Failed to execute loader thread for liboainject.dylib #78

Closed washanhanzi closed 1 year ago

washanhanzi commented 1 year ago

The command report the following error:

cargo instruments -t Allocations --bin struct_with_string_test
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
   Profiling target/debug/struct_with_string_test with template 'Allocations'
      Failed instruments errored: Run issues were detected (trace is still ready to be viewed):
* [Error] Failed to attach to target process

    * [Error] Failed to execute loader thread for /Applications/Xcode.app/Contents/SharedFrameworks/DVTInstrumentsFoundation.framework/Resources/liboainject.dylib in target; target process 97865 likely exited

The instruments file are generated, and I can open the file with instruments. instruments showed the same error. I'm not familiar with instruments and xcode, could you provide me with some information so I can debug the problem?

cmyr commented 1 year ago

This sounds like a problem related to instruments itself, and I don't have a lot of insight there. Can you launch the instruments GUI app (bundled with Xcode)?

washanhanzi commented 1 year ago

Yes I can. I can launch the app and open the instruments file generated by cargo instruments. But in GUI it showed the same error.

cmyr commented 1 year ago

can you launch the app and record new traces from within it? This sounds like a problem with Xcode/Instruments that is unrelated to cargo-instruments, and I haven't encountered it before. If you can't find anything, I would try uninstalling and reinstalling Xcode. :/

washanhanzi commented 1 year ago

I looked around and find maybe it was because my program is too simple. The program finishes before Instruments can start profiling. Then I tested with a line of thread::sleep, and it works fine.

Thanks for your time.

Closing.

samuelcolvin commented 1 year ago

thanks so much @washanhanzi (and @cmyr for this great package 🙏) I've just run into the same problem with latest xcode 14.

Solution was to add std::thread::sleep(std::time::Duration::from_millis(10)) just before exiting.

cmyr commented 1 year ago

Was this working for either of you before Xcode 14? I'm curious if this is a change, or just a coincidence.

samuelcolvin commented 1 year ago

I tried cargo-instruments for the first time yesterday, so I'm afraid I can't help on that.

washanhanzi commented 1 year ago

Same for me. Never used it before.