holy-lambda

octahedrion 2024-05-20T10:07:57.995259Z

what does it mean if my built output runs in the docker container in which it was built but doesn't in AL2 ? I thought Graal native image packaged all the .so s needed inside the build

Karol Wójcik 2024-05-20T12:04:36.318049Z

What options are you using for building native-executable?

octahedrion 2024-05-20T13:46:24.392569Z

"--verbose"
"--no-fallback"
"-Djava.awt.headless=false"
"--report-unsupported-elements-at-runtime"
"-H:-UseServiceLoaderFeature"
"--no-server"
it appears to be awt related

Karol Wójcik 2024-05-20T14:24:03.798799Z

Could you kindly share the error message?

Karol Wójcik 2024-05-20T14:24:51.022209Z

Please be aware that image in which HL builds your lambda is not exactly the same. HL uses oraclelinux for building ;)

octahedrion 2024-05-21T09:23:17.931089Z

I used my own docker image based on AL2 with the latest GraalVM to build it instead of the default HL image. I think my java.library.path is wrong

Karol Wójcik 2024-05-21T10:47:28.509869Z

I’m not seeing the error message so i can’t help ;)

octahedrion 2024-05-21T11:16:35.415369Z

java.lang.UnsatisfiedLinkError: Can't load library: awt | java.library.path = [/opt/graalvm-jdk-22+36.1/lib/, /usr/lib64, /lib64, /lib, /usr/lib]
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibraries.loadLibraryRelative(NativeLibraries.java:141)
	at java.base@22/java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
	at java.base@22/java.lang.Runtime.loadLibrary0(Runtime.java:916)
	at java.base@22/java.lang.System.loadLibrary(System.java:2068)
	at java.desktop@22/java.awt.image.ColorModel$1.run(ColorModel.java:211)
	at java.desktop@22/java.awt.image.ColorModel$1.run(ColorModel.java:209)
	at java.base@22/java.security.AccessController.executePrivileged(AccessController.java:128)
	at java.base@22/java.security.AccessController.doPrivileged(AccessController.java:319)
	at java.desktop@22/java.awt.image.ColorModel.loadLibraries(ColorModel.java:208)
	at java.desktop@22/java.awt.image.ColorModel.<clinit>(ColorModel.java:221)...

Karol Wójcik 2024-05-21T11:17:26.724039Z

Are you using anything AWT related?

octahedrion 2024-05-21T11:17:55.113959Z

yes

Karol Wójcik 2024-05-21T11:25:40.432569Z

Lambda doesn’t have AWT included by default. You need to pack the library in the zip and use LD_PRELOAD as shown here: https://github.com/quarkusio/quarkus/issues/23998

Karol Wójcik 2024-05-21T11:26:03.764439Z

Another option is to run your lambda in docker image.

octahedrion 2024-05-21T13:22:29.532749Z

ahhhh. I had assumed that the awt was included into the built output because libawt.so, libawt_headless.so, libawt_xawt.so etc appear in the /holy-lambda/build/native/ folder, which I believe is where native resources are copied prior to being packaged into the built binary, from where during execution they'd be dynamically linked

Karol Wójcik 2024-05-21T13:25:14.526339Z

If the files are there it means that on AWS Lambda Environment they gonna appear under /var/task

octahedrion 2024-05-21T13:26:49.332939Z

meaning the first method you suggested could work

Karol Wójcik 2024-05-21T13:27:42.689569Z

Yup, potentially it should work. If yes, then we can add this variable to bootstrap script :)

octahedrion 2024-05-21T14:18:50.157699Z

testing locally in the docker container of the image I used to build it I get

Fatal error reported via JNI: Could not allocate library name

Printing instructions (ip=0x000000000056c4ac):
  0x000000000056c3ac: 0xe0 0x03 0x1f 0xaa 0xfb 0x73 0x46 0xa9 0xfd 0x7b 0x4f 0xa9 0xff 0x03 0x04 0x91
  0x000000000056c3bc: 0xc0 0x03 0x5f 0xd6 0xee 0xbf 0x46 0xad 0xec 0xb7 0x45 0xad 0xea 0xaf 0x44 0xad
  0x000000000056c3cc: 0xe8 0xa7 0x43 0xad 0xe1 0x0b 0x46 0xa9 0xf9 0x6b 0x45 0xa9 0xf7 0x63 0x44 0xa9
  0x000000000056c3dc: 0xf5 0x5b 0x43 0xa9 0xf3 0x53 0x42 0xa9 0x00 0x00 0x1b 0xcb 0x00 0xfc 0x43 0xd3
  0x000000000056c3ec: 0x80 0xb3 0x00 0xb9 0xe0 0x07 0x00 0x32 0x88 0x53 0x00 0x91 0x00 0xfd 0x9f 0x88...
(very long dump leading back to the original stacktrace above)
that's using export LD_PRELOAD="/opt/graalvm-jdk-22+36.1/lib/libawt.so ... other .so files there's probably something I'm missing as I've been staring at the problem too long so I'll try again tomorrow