codeql-cli-binaries icon indicating copy to clipboard operation
codeql-cli-binaries copied to clipboard

Xcode iOS simulator build fails when codeql is injected

Open BretJohnson opened this issue 2 years ago • 14 comments

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.

BretJohnson avatar Dec 09 '22 21:12 BretJohnson

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?

MathiasVP avatar Dec 12 '22 14:12 MathiasVP

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 avatar Dec 13 '22 06:12 BretJohnson

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

BretJohnson avatar Dec 15 '22 07:12 BretJohnson

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.

MathiasVP avatar Dec 15 '22 13:12 MathiasVP

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

BretJohnson avatar Jan 03 '23 13:01 BretJohnson

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.

adityasharad avatar Jan 11 '23 18:01 adityasharad

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

mariaghiondea avatar Jan 25 '23 00:01 mariaghiondea

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.

adityasharad avatar Jan 25 '23 15:01 adityasharad

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

BretJohnson avatar Feb 20 '23 16:02 BretJohnson

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

MathiasVP avatar Feb 20 '23 16:02 MathiasVP

@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 avatar Feb 26 '23 00:02 BretJohnson

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 avatar Mar 07 '23 16:03 BretJohnson

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

BretJohnson avatar Mar 20 '23 23:03 BretJohnson

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.

aibaars avatar Mar 21 '23 09:03 aibaars