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

Native Libraries cannot be loaded with 11.0.4 on Mojave #1211

Closed
timyates opened this issue Aug 9, 2019 · 20 comments
Closed

Native Libraries cannot be loaded with 11.0.4 on Mojave #1211

timyates opened this issue Aug 9, 2019 · 20 comments
Assignees
Labels
bug Issues that are problems in the code as reported by the community macos Issues that affect or relate to the MAC OS testing Issues that enhance or fix our test suites
Milestone

Comments

@timyates
Copy link

timyates commented Aug 9, 2019

Platform:

OSX Mojave

Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64

Architecture:

x86_64

Issue description

When attempting to load native libraries on the above platform with any of the 11.0.4 builds, I get an exception:

/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib: code signature in (/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

When running with 11.0.3, everything works as expected.

Reproducible test

There is a java app over here: https://bintray.com/beta/#/adammurdoch/maven/net.rubygrapefruit:native-platform-test/0.18?tab=files which tests various native calls.

If you download the zip, and unpack it, I get the following results:

11.0.3 (Good)

$ bin/native-platform-test

Select test to run:
  1) Show terminal details
  2) Show machine details
  3) Show file systems
  4) Test input handling
  5) Example prompts
> 6) Exit
Use the arrow keys to select an option and press enter

11.0.4 (Bad)

$ bin/native-platform-test
Exception in thread "main" net.rubygrapefruit.platform.NativeIntegrationLinkageException: Native library 'libnative-platform.dylib' could not be loaded for Mac OS X x86_64.
	at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:61)
	at net.rubygrapefruit.platform.Native.init(Native.java:55)
	at net.rubygrapefruit.platform.Native.get(Native.java:80)
	at net.rubygrapefruit.platform.test.Main.terminals(Main.java:286)
	at net.rubygrapefruit.platform.test.Main.main(Main.java:109)
Caused by: java.lang.UnsatisfiedLinkError: /private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib: dlopen(/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib, 1): no suitable image found.  Did find:
	/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib: code signature in (/private/var/folders/f6/c8gfypz56c5d9b66l6_1n30m0000gn/T/native-platform4313193693498570932dir/libnative-platform.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2430)
	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2487)
	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2684)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2617)
	at java.base/java.lang.Runtime.load0(Runtime.java:767)
	at java.base/java.lang.System.load(System.java:1831)
	at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:51)
	... 4 more

I suspect this is an OS X only thing, but I'm testing it on ubuntu to make sure

@timyates
Copy link
Author

timyates commented Aug 9, 2019

Tested on Ubuntu, and both version work as expected...

This seems to be just an OS X issue

@taubeklavs
Copy link

I am also experiencing the same issue on macos with jdk-11.0.4+11.2, reverting to jdk-11.0.3+7 works.

@karianna karianna added this to TODO in temurin-build via automation Aug 13, 2019
@karianna karianna added the bug Issues that are problems in the code as reported by the community label Aug 13, 2019
@karianna karianna added this to the August 2019 milestone Aug 13, 2019
@karianna
Copy link
Contributor

@gdams likely related to the other issues you're working on...

@gdams
Copy link
Member

gdams commented Aug 13, 2019

@taubeklavs we have a fix in place for this and are in the process of creating a jdk-11.0.4+11.3 release. Apologies for the inconvenience

@gdams gdams closed this as completed Aug 13, 2019
temurin-build automation moved this from TODO to Done Aug 13, 2019
@timyates
Copy link
Author

Awesome thanks! 😎👍

Not sure how I missed #1206 Sorry about that 😞

@sjuxax
Copy link

sjuxax commented Aug 14, 2019

Doesn't look like that build is out yet and issue was blocking something I'm working on -- for anyone else in the same boat, you should be able to:

brew cask reinstall https://raw.githubusercontent.com/AdoptOpenJDK/homebrew-openjdk/c017a832eec4f940e11c139b6e7852eeb3b2aad8/Casks/adoptopenjdk11.rb

to get the adoptopenjdk11 cask to read out like so:

$ brew cask info adoptopenjdk11
adoptopenjdk11: 11,0.3:7
https://adoptopenjdk.net/
/usr/local/Caskroom/adoptopenjdk11/11,0.3:7 (181.4MB)
From: https://github.com/adoptopenjdk/homebrew-openjdk/blob/master/Casks/adoptopenjdk11.rb
==> Name
AdoptOpenJDK 11
==> Artifacts
OpenJDK11U-jdk_x64_mac_hotspot_11.0.3_7.pkg (Pkg)

Once the new build is published, simple brew cask upgrade should pick it up. :)

@bberstel
Copy link

Save erroneous behavior occurs with

openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)

I just downloaded jdk-12.0.2+10.2 and ran the native-platform-test. I got the "Bad" trace reported by OP.

Any hope to get a fixed build?

@ktulinger
Copy link

Hi, can confirm this also on the version 12.

@timyates
Copy link
Author

Just checked the latest 11.0.5

openjdk version "11.0.5" 2019-10-15

And this all works on OS X 😎 🎉

Closing this

Thanks all!

temurin-build automation moved this from In Progress to Done Nov 15, 2019
@MRigal
Copy link

MRigal commented Apr 30, 2020

I have this problem with 14.0.1 and 11.0.7 on Catalina

@karianna
Copy link
Contributor

karianna commented May 1, 2020

@MRigal How did you install the binary - was it a PKG file via homebrew?

@karianna karianna reopened this May 1, 2020
temurin-build automation moved this from Done to In Progress May 1, 2020
@karianna karianna added the macos Issues that affect or relate to the MAC OS label May 1, 2020
@MRigal
Copy link

MRigal commented May 1, 2020 via email

@peter-gerhard
Copy link

I'm still having this issue with adoptopenjdk12 and osx catalina

os: mac osx catalina 10.15.4
jdk: installed via

▶ brew tap adoptopenjdk/openjdk
▶ brew cask install adoptopenjdk --no-quarantine

brew installed the jdk under /Library/Java/JavaVirtualMachines/

▶ java --version
openjdk 12.0.2 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.2+10, mixed mode)

sbt installed via:

▶ brew install sbt
▶ sbt sbtVersion
[info] 	1.3.10

Some people suggested that this is an issue with gatekeeper from osx but if I globally disable the gatekeeper the issue persists:

▶ sudo spctl --master-disable
▶ spctl --status
assessments disabled

# starting sbt will produce the same output (code signature in [...] not valid for use in process using Library Validation: mapped file has no cdhash)

▶ sudo spctl --master-enable
▶ spctl --status
assessments enabled

Checking the item shows that it is indeed not signed

▶ codesign -dv --verbose=4 ~/Library/Caches/JNA/temp/jna123.tmp
~/Library/Caches/JNA/temp/jna123.tmp: code object is not signed at all

Checking the /Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Info.plist I can see the following:

	<key>CFBundleSignature</key>
	<string>????</string>

This is apparently the default on initialisation of new xcode projects and has not been changed?!

@aahlenst
Copy link
Contributor

@peter-gerhard There's no hardened runtime and notarization support on OpenJDK 12 and there won't be because it has reached its EOL.

@aahlenst
Copy link
Contributor

Furthermore, I'm closing this issue because 11.0.7's PKG is fully notarized.

temurin-build automation moved this from In Progress to Done May 19, 2020
@vsgopinath
Copy link

@aahlenst I found out the /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Info.plist does not have the bundle signature.

<key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>11.0.7</string>

Which version is currently code signed as I tried 11 and 12 version already

@aahlenst
Copy link
Contributor

8u252.1, 11.0.7 and 14 are notarized. You need the PKG, however.

@MRigal
Copy link

MRigal commented Jan 8, 2021

@aahlenst FYI this was not fixed in 11.0.7 nor in 11.0.8, but it is indeed fixed in 11.0.9

@cmota
Copy link

cmota commented Mar 16, 2021

If anyone got to this thread due while trying to compile a KMM project, I was able to fix it by upgrading gradle version to 7.0.0-alpha09.

@cyb3rsalih
Copy link

cyb3rsalih commented Nov 13, 2021

getting same issue on building apk with flutter 2.5.3.
I use jdk-11.0.11 btw.
It is strange that, there is error but my build is succeed. And apk works.

@github-actions github-actions bot added the testing Issues that enhance or fix our test suites label Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that are problems in the code as reported by the community macos Issues that affect or relate to the MAC OS testing Issues that enhance or fix our test suites
Projects
No open projects
temurin-build
  
Done
Development

No branches or pull requests