Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode iOS simulator build fails when codeql is injected #147

Open
BretJohnson opened this issue Dec 9, 2022 · 14 comments
Open

Xcode iOS simulator build fails when codeql is injected #147

BretJohnson opened this issue Dec 9, 2022 · 14 comments
Labels

Comments

@BretJohnson
Copy link

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.

@github-actions github-actions bot added the CLI label Dec 9, 2022
@MathiasVP
Copy link

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?

@BretJohnson
Copy link
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.

@BretJohnson
Copy link
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.

@MathiasVP
Copy link

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.

@BretJohnson
Copy link
Author

BretJohnson commented Jan 3, 2023

@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.

@adityasharad
Copy link
Contributor

adityasharad commented Jan 11, 2023

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.

@mariaghiondea
Copy link

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

@adityasharad
Copy link
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.

@BretJohnson
Copy link
Author

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

@MathiasVP
Copy link

2.12.2 has been released. See https://github.com/github/codeql-cli-binaries/releases/tag/v2.12.2 🙂.

@BretJohnson
Copy link
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

@BretJohnson
Copy link
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.

@BretJohnson
Copy link
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.

@aibaars
Copy link
Contributor

aibaars commented Mar 21, 2023

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
Labels
Projects
None yet
Development

No branches or pull requests

5 participants