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

Mac M1: dyld: could not load inserted library #109

Open
alioth310 opened this issue Jan 26, 2022 · 4 comments
Open

Mac M1: dyld: could not load inserted library #109

alioth310 opened this issue Jan 26, 2022 · 4 comments
Assignees
Labels

Comments

@alioth310
Copy link

Hello,

When I use CodeQL to create database, I got following error:

% codeql database create tdb --language=java                             
Initializing database at /Users/admin/Documents/codeql-home/repo/xxx/java-db.
Running build command: [/Users/admin/Documents/codeql-home/codeql/java/tools/autobuild.sh]
[2022-01-26 21:17:40] [build-stdout] [2022-01-26 21:17:40] Build directory is .
[2022-01-26 21:17:40] [build-stdout] [2022-01-26 21:17:40] [autobuild] > mvn clean package -f "pom.xml" -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip.exec -Dlicense.skip=true -Drat.skip=true 
[2022-01-26 21:17:40] [build-stdout] [2022-01-26 21:17:40] [ERROR] Spawned process exited abnormally (code 134; tried to run: [mvn, clean, package, -f, pom.xml, -B, -V, -e, -Dfindbugs.skip, -Dcheckstyle.skip, -Dpmd.skip=true, -Denforcer.skip, -Dmaven.javadoc.skip, -DskipTests, -Dmaven.test.skip.exec, -Dlicense.skip=true, -Drat.skip=true])
[2022-01-26 21:17:40] [build-stdout] [2022-01-26 21:17:40] [autobuild] dyld: could not load inserted library '/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib' because no suitable image found.  Did find:
[2022-01-26 21:17:40] [build-stdout] [2022-01-26 21:17:40] [autobuild] 	/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: no matching architecture in universal wrapper
[2022-01-26 21:17:40] [build-stdout] [2022-01-26 21:17:40] [autobuild] 	/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: stat() failed with errno=1
[2022-01-26 21:17:40] [ERROR] Spawned process exited abnormally (code 134; tried to run: [/Users/admin/Documents/codeql-home/codeql/tools/osx64/preload_tracer, /Users/admin/Documents/codeql-home/codeql/java/tools/autobuild.sh])
A fatal error occurred: Exit status 134 from command: [/Users/admin/Documents/codeql-home/codeql/java/tools/autobuild.sh]

Version:

I changed CodeQL to Ubuntu ARM64 virtual machine (Using UTM), then the error changed to: java: Exec format error

And then I use an old macbook, finally success.

So I think the problem is M1. Can I do something to resolve this problem?

@github-actions github-actions bot added the CLI label Jan 26, 2022
@aibaars
Copy link
Contributor

aibaars commented Jan 31, 2022

Thanks for reporting this. The error message on Ubuntu ARM is expected. CodeQL only supports arm64 for OSX at the moment.

We tried the 2.7.6 version of CodeQL on macOS 12 (Monterey) with a simple mvn build and things work fine. Perhaps the way we generate the universal binary somehow does not work on macOS: Big Sur (11.6) .

To debug things further, could you:

  • run codeql version to double check you got the most recent version
  • run file /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib to check which architectures the library contains
  • (if you have time) look into the tdb/log/build-tracer.log for clues of what might be going wrong. You can also share the entire file if you wish; however, it can be quite large and may contain sensitive file names etc you might not want to share in a public issue.

@alioth310
Copy link
Author

  1. The result of codeql version:
% codeql version
CodeQL command-line toolchain release 2.7.6.
Copyright (C) 2019-2022 GitHub, Inc.
Unpacked in: /Users/admin/Documents/codeql-home/codeql
   Analysis results depend critically on separately distributed query and
   extractor modules. To list modules that are visible to the toolchain,
   use 'codeql resolve qlpacks' and 'codeql resolve languages'.
  1. The result of file libtrace.dylib:
% file /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib
/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64:Mach-O 64-bit dynamically linked shared library arm64]
/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64
  1. I rerun the codeql database create command, and the following is the content of build-tracer.log file.
[T 10:32:49 40171] Reading configuration file /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/tracing/compiler-tracing5537207723357565246.spec...
[T 10:32:49 40171] Initialising tags...
[T 10:32:49 40171] ID set to 0000000000009CEB_0000000000000001 (parent root)
[T 10:32:49 40171] Reading configuration file /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/tracing/compiler-tracing5537207723357565246.spec...
[T 10:32:49 40171] Initialising tags...
[T 10:32:49 40171] ID set to 0000000000009CEB_0000000000000002 (parent root)
[T 10:32:49 40171] Warning: SEMMLE_EXEC and SEMMLE_EXECP not set. Falling back to path lookup on argv[0].
[T 10:32:49 40171] ==== Candidate to intercept: /Users/admin/Documents/codeql-home/codeql/tools/osx64/runner-osx (canonical: /Users/admin/Documents/codeql-home/codeql/tools/osx64/runner-osx) ====
[T 10:32:49 40172] Attempting to switch stdout/stderr to 3...
dyld: could not load inserted library '/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib' because no suitable image found.  Did find:
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: no matching architecture in universal wrapper
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: stat() failed with errno=1

relocator: cannot re-sign the slice: /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/copy-root/000001F5/bin/bash.semmle.00009CEB.slice.x86_64
[T 10:32:49 40171] Reading configuration file /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/tracing/compiler-tracing5537207723357565246.spec...
[T 10:32:49 40171] Initialising tags...
[T 10:32:49 40171] ID set to 0000000000009CEB_0000000000000003 (parent 0000000000009CEB_0000000000000002)
[T 10:32:49 40171] ==== Candidate to intercept: /Users/admin/Documents/codeql-home/codeql/java/tools/autobuild.sh (canonical: /Users/admin/Documents/codeql-home/codeql/java/tools/autobuild.sh) ====
[T 10:32:49 40175] Attempting to switch stdout/stderr to 3...
dyld: could not load inserted library '/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib' because no suitable image found.  Did find:
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: no matching architecture in universal wrapper
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: stat() failed with errno=1

relocator: cannot patch install names (rpaths) for slice: /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/copy-root/000001F5/Users/admin/Documents/codeql-home/codeql/tools/osx64/java-aarch64/bin/java.semmle.00009CEE.slice.arm64
[T 10:32:49 40174] Reading configuration file /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/tracing/compiler-tracing5537207723357565246.spec...
[T 10:32:49 40174] Initialising tags...
[T 10:32:49 40174] ID set to 0000000000009CEE_0000000000000001 (parent 0000000000009CEB_0000000000000003)
[T 10:32:49 40174] ==== Candidate to intercept: /Users/admin/Documents/codeql-home/codeql/tools/osx64/java-aarch64/bin/java (canonical: /Users/admin/Documents/codeql-home/codeql/tools/osx64/java-aarch64/bin/java) ====
[T 10:32:49 40174] Loading extra JVM options from SEMMLE_JAVA_TOOL_OPTIONS instead of in-process variable.
[T 10:32:49 40174] Passing through -javaagent:/Users/admin/Documents/codeql-home/codeql/java/tools/codeql-java-agent.jar=ignore-project,java to underlying JVM.
[T 10:32:49 40174] Passing through -Xbootclasspath/a:/Users/admin/Documents/codeql-home/codeql/java/tools/codeql-java-agent.jar to underlying JVM.
[T 10:32:49 40174] Intercepted JVM creation with extra hidden args: ['-javaagent:/Users/admin/Documents/codeql-home/codeql/java/tools/codeql-java-agent.jar=ignore-project,java' '-Xbootclasspath/a:/Users/admin/Documents/codeql-home/codeql/java/tools/codeql-java-agent.jar'] (result: 1, 0).
[T 10:32:50 40181] Attempting to switch stdout/stderr to 18...
dyld: could not load inserted library '/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib' because no suitable image found.  Did find:
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: no matching architecture in universal wrapper
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: stat() failed with errno=1

relocator: cannot re-sign the slice: /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/copy-root/000001F5/Users/admin/Documents/codeql-home/codeql/tools/osx64/java-aarch64/lib/jspawnhelper.semmle.00009CEE.slice.arm64
[T 10:32:50 40183] Reading configuration file /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/tracing/compiler-tracing5537207723357565246.spec...
[T 10:32:50 40183] Initialising tags...
[T 10:32:50 40183] ID set to 0000000000009CF7_0000000000000001 (parent 0000000000009CEE_0000000000000001)
[T 10:32:50 40183] ==== Candidate to intercept: /Users/admin/Documents/codeql-home/codeql/tools/osx64/java-aarch64/lib/jspawnhelper (canonical: /Users/admin/Documents/codeql-home/codeql/tools/osx64/java-aarch64/lib/jspawnhelper) ====
[T 10:32:50 40184] Attempting to switch stdout/stderr to 4...
dyld: could not load inserted library '/Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib' because no suitable image found.  Did find:
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: no matching architecture in universal wrapper
   /Users/admin/Documents/codeql-home/codeql/tools/osx64/libtrace.dylib: stat() failed with errno=1

relocator: cannot re-sign the slice: /Users/admin/Documents/codeql-home/repo/xxx/java-database/working/copy-root/000001F5/bin/sh.semmle.00009CF7.slice.x86_64

@aibaars
Copy link
Contributor

aibaars commented Feb 7, 2022

Many thanks for the detailed report. I'll pass this on to the team.

@safe6Sec
Copy link

@aibaars Is this problem solved?

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

4 participants