Skip to content

Xcode iOS simulator build fails when codeql is injected #147

Description

@BretJohnson

When CodeQL is enabled for our repo here https://github.com/xamarin/ios-sim-sharp, the build crashes, with codeql is on the call stack.

See the attached: failure.log

The error below also appears in the log:

2022-11-18T14:31:19.4879860Z   dyld: dyld cache load error: shared cache file open() failed
2022-11-18T14:31:19.4882650Z   dyld: could not load inserted library '/Users/runner/work/_temp/codeql3000/github/codeql/tools/osx64/libtrace.dylib' because no suitable image found.  Did find:
2022-11-18T14:31:19.4885600Z    /Users/runner/work/_temp/codeql3000/github/codeql/tools/osx64/libtrace.dylib: mach-o, but not built for platform iOS-sim

success.log is the same build, without codeql enabled, so that you can compare.

Also attached is codeql-init.log, with the output of the CodeQL init task.

I tested with the latest codeql, 2.11.4, and the error still happens.

Thanks for investigating & hopefully fixing or suggesting a workaround.

Activity

  1. MathiasVP commented on Dec 12, 2022

    @MathiasVP

    Hi @BretJohnson,

    Thanks for your issue. We're trying to reproduce your issue, but without any luck so far.

    Could you please tell us what kind of environment (i.e., OS and hardware) you're running on?

  2. BretJohnson commented on Dec 13, 2022

    @BretJohnson
    Author

    Here is a build pipeline that fails, which may help: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=7081421&view=logs&j=2531f56b-95d7-58fc-e11b-e55dd667c1ed&t=c0ac43a8-fd5c-5003-10b7-fe1098fdc19d. Let me know if you don't have access.

    The hardware / OS is (I'm pretty sure) an Intel based Mac running macOS 11 (Big Sur). It's the internal-macos11 image for us. I will try with macos12 (Monterey) to see if it makes a difference.

  3. BretJohnson commented on Dec 15, 2022

    @BretJohnson
    Author

    @MathiasVP - No difference with Monterey. Would access to the https://github.com/xamarin/ios-sim-sharp help? I just granted you access - look for an invite to accept. If you clone you should be able to build locally. Note that the build currently uses Xcode 12.5 - a bit old, but required currently for builds. That may be part of the issue - you may need Xcode 12.5 to repro. You can install it from here: https://developer.apple.com/download/all/?q=xcode. Thanks.

  4. MathiasVP commented on Dec 15, 2022

    @MathiasVP

    Sorry about the delay, @BretJohnson. Thanks for the invitation. I've accepted it now. We can reproduce your issue and we're looking into a solution. Will keep you updated on this issue.

  5. BretJohnson commented on Jan 3, 2023

    @BretJohnson
    Author

    @MathiasVP - I hope you all had a good holiday break. Please holler when you have any updates here. We'd like to complete our CodeQL compliance work and this is a blocker for us. Thx again for your help.

  6. adityasharad commented on Jan 11, 2023

    @adityasharad
    Contributor

    Quick update: We're still figuring out the solution here, but suspect the underlying problem is that the CodeQL build tracer (which instruments your build to obtain information from the compilers while they run) does not correctly handle binaries built to target the ios-sim platform, and is incorrectly attempting to handle them as standard mach-o binaries.
    We have two possible strategies in mind, but need to experiment with each before we can offer you a solution to test:

    • Short-term: Identify the exact name of the binary in your build that is targeting ios-sim, and update our build tracer configuration to ignore this binary.
    • Long-term: Teach the build tracer on macOS to ignore all binaries in general that are not built for the macOS target platform.
  7. mariaghiondea commented on Jan 25, 2023

    @mariaghiondea

    Any updates on this? It's still blocking our teams from enabling CodeQL (on 2-3 repos)

  8. adityasharad commented on Jan 25, 2023

    @adityasharad
    Contributor

    Thanks for your patience and the reminder. We have implemented the long-term fix I outlined above and it will be included in CodeQL 2.12.2, which will be rolled out from mid-February.

  9. BretJohnson commented on Feb 20, 2023

    @BretJohnson
    Author

    @adityasharad Can you say if CodeQL 2.12.2 is available yet or, if not, about when it will be available. Thanks much.

  10. MathiasVP commented on Feb 20, 2023

    @MathiasVP
  11. BretJohnson commented on Feb 26, 2023

    @BretJohnson
    Author

    @MathiasVP 2.12.2 was released (per the link above) 3 weeks ago but it looks like the CodeQL task we're using is still on 2.12.1 by default. I can force use of the newer version with the variables below if I can get the hash for the 2.12.2 release. Do you know where to get that, the release hash? Thanks.

    Example of forcing explicit codeql version:
    CodeQL.CLIVersion: 2.11.4
    CodeQL.CLIHash: d2af01639c3823249b111696f79dc611e08a7b1799b034b3cb304fa21f09bed9

  12. BretJohnson commented on Mar 7, 2023

    @BretJohnson
    Author

    Update: I found the steps and force of 2.12.2 now. Unfortunately, I still see the codeql related build error on it: " LaunchScreen.storyboard : error : dyld: could not load inserted library '/Users/runner/work/_temp/codeql3000/github/codeql/tools/osx64/libtrace.dylib' because no suitable image found. Did find: [/Users/runner/work/1/s/MonoTouch.Hosting.Tests.iOS/MonoTouch.Hosting.Tests.iOS.csproj]".

    The build is here: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=7432542&view=logs&j=2531f56b-95d7-58fc-e11b-e55dd667c1ed&t=c0ac43a8-fd5c-5003-10b7-fe1098fdc19d

    Can you please take a look. Thanks.

  13. BretJohnson commented on Mar 20, 2023

    @BretJohnson
    Author

    @MathiasVP / others - Ping on this. The problem is still happening, even with CodeQL 2.12.2. See above. Can you please take a look. Thanks.

  14. aibaars commented on Mar 21, 2023

    @aibaars
    Contributor

    Thanks for following up on this. This part of the error message seems relevant mach-o, but not built for platform iOS-sim. I'll ask a colleague to have a look at this.

    Guessing from the project name, it appears the failure happens in test code. You could try skipping the test execution or excluding the test project from the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions