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

Runtime SIGSEGV thrown on Linux ARM64 (libskiko-linux-arm64.so) #838

Open
kikermo opened this issue Dec 10, 2023 · 21 comments
Open

Runtime SIGSEGV thrown on Linux ARM64 (libskiko-linux-arm64.so) #838

kikermo opened this issue Dec 10, 2023 · 21 comments

Comments

@kikermo
Copy link

kikermo commented Dec 10, 2023

Hi, I am trying to run a project with Compose Multiplaftorm but have a runtime failure when running it on arm64 Linux (Raspberry Pi).

It was tested on 0.7.85.0 and v0.7.89.1 with Java 17 and 18.

Stacktrace:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000000000, pid=5731, tid=5761
#
# JRE version: OpenJDK Runtime Environment (17.0.9+9) (build 17.0.9+9-Debian-1deb12u1)
# Java VM: OpenJDK 64-Bit Server VM (17.0.9+9-Debian-1deb12u1, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# C  [libskiko-linux-arm64.so+0x5fe9c8]  GrGLBuffer::onUpdateData(void const*, unsigned long, unsigned long, bool)+0xc8
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   https://bugs.debian.org/openjdk-17
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  S U M M A R Y ------------

Command Line: -Dcompose.application.configure.swing.globals=true -Dcompose.application.resources.dir=/home/kikermo/mainframer/Matrix8/composeApp/build/compose/tmp/prepareAppResources -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant org.kikermo.matrix8.MainKt

Host: AArch64, 4 cores, 3G, Debian GNU/Linux 12 (bookworm)
Time: Sun Dec 10 12:12:04 2023 GMT elapsed time: 1.801942 seconds (0d 0h 0m 1s)

---------------  T H R E A D  ---------------

Current thread (0x00007fffa4590ac0):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=5761, stack(0x00007fff40250000,0x00007fff40450000)]

Stack: [0x00007fff40250000,0x00007fff40450000],  sp=0x00007fff4044ae30,  free space=2027k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libskiko-linux-arm64.so+0x5fe9c8]  GrGLBuffer::onUpdateData(void const*, unsigned long, unsigned long, bool)+0xc8
C  [libskiko-linux-arm64.so+0x5d0768]  GrBufferAllocPool::unmap()+0x164

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.jetbrains.skia.DirectContextKt.DirectContext_nFlush(J)V+0
j  org.jetbrains.skia.DirectContextKt.access$DirectContext_nFlush(J)V+1
j  org.jetbrains.skia.DirectContext.flush()Lorg/jetbrains/skia/DirectContext;+10
j  org.jetbrains.skiko.context.ContextHandler.flush()V+8
j  org.jetbrains.skiko.context.ContextHandler.draw()V+72
j  org.jetbrains.skiko.redrawer.LinuxOpenGLRedrawer.redrawImmediately()V+231
j  org.jetbrains.skiko.SkiaLayer.paint(Ljava/awt/Graphics;)V+102
j  androidx.compose.ui.awt.WindowComposeBridge$component$1.paint(Ljava/awt/Graphics;)V+15
j  javax.swing.JComponent.paintChildren(Ljava/awt/Graphics;)V+523 java.desktop@17.0.9
j  javax.swing.JComponent.paint(Ljava/awt/Graphics;)V+318 java.desktop@17.0.9
j  javax.swing.JLayeredPane.paint(Ljava/awt/Graphics;)V+73 java.desktop@17.0.9
j  javax.swing.JComponent.paintChildren(Ljava/awt/Graphics;)V+523 java.desktop@17.0.9
j  javax.swing.JComponent.paint(Ljava/awt/Graphics;)V+318 java.desktop@17.0.9
j  androidx.compose.ui.window.Window_desktopKt$Window$12$1.invoke(Landroidx/compose/ui/awt/ComposeWindow;)V+86
j  androidx.compose.ui.window.Window_desktopKt$Window$12$1.invoke(Ljava/lang/Object;)Ljava/lang/Object;+5
j  androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$3.invoke()V+13
j  androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$3.invoke()Ljava/lang/Object;+1
j  androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2$performUpdate$1.invoke()V+7
j  androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2$performUpdate$1.invoke()Ljava/lang/Object;+1
j  androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;+108
j  androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)V+106
j  androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)V+92
j  androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke$performUpdate(Landroidx/compose/runtime/snapshots/SnapshotStateObserver;Lkotlin/jvm/internal/Ref$ObjectRef;Landroidx/compose/runtime/State;)V+38
j  androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke(Landroidx/compose/runtime/DisposableEffectScope;)Landroidx/compose/runtime/DisposableEffectResult;+59
j  androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke(Ljava/lang/Object;)Ljava/lang/Object;+5
j  androidx.compose.runtime.DisposableEffectImpl.onRemembered()V+8
j  androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers()V+365
j  androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Ljava/util/List;)V+246
j  androidx.compose.runtime.CompositionImpl.applyChanges()V+38
j  androidx.compose.runtime.Recomposer.composeInitial$runtime(Landroidx/compose/runtime/ControlledComposition;Lkotlin/jvm/functions/Function2;)V+267
j  androidx.compose.runtime.CompositionImpl.setContent(Lkotlin/jvm/functions/Function2;)V+55
j  androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;+89
j  kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Ljava/lang/Object;)V+44
j  kotlinx.coroutines.DispatchedTask.run()V+317
j  java.awt.event.InvocationEvent.dispatch()V+47 java.desktop@17.0.9
j  java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+21 java.desktop@17.0.9
j  java.awt.EventQueue$4.run()Ljava/lang/Void;+32 java.desktop@17.0.9
j  java.awt.EventQueue$4.run()Ljava/lang/Object;+1 java.desktop@17.0.9
j  java.security.AccessController.executePrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/lang/Class;)Ljava/lang/Object;+29 java.base@17.0.9
j  java.security.AccessController.doPrivileged(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;)Ljava/lang/Object;+13 java.base@17.0.9
j  java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Ljava/security/PrivilegedAction;Ljava/security/AccessControlContext;Ljava/security/AccessControlContext;)Ljava/lang/Object;+18 java.base@17.0.9
j  java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V+46 java.desktop@17.0.9
j  java.awt.EventDispatchThread.pumpOneEventForFilters(I)V+78 java.desktop@17.0.9
j  java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35 java.desktop@17.0.9
j  java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11 java.desktop@17.0.9
j  java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4 java.desktop@17.0.9
j  java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3 java.desktop@17.0.9
j  java.awt.EventDispatchThread.run()V+9 java.desktop@17.0.9
v  ~StubRoutines::call_stub

siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000000
@loukwn
Copy link

loukwn commented Dec 30, 2023

Hi @kikermo I am facing the same issue. I wanted to ask how did you change the version of skiko? Do you just declare it in the build.gradle.kts? Nvm I should have seen the README.md

Just to add to this issue I also get the same error on the Raspberry Pi when running the template Compose Multiplatform for Desktop app.

@loukwn
Copy link

loukwn commented Dec 30, 2023

@kikermo Seems like this helped me: #649 (For the Compose Multiplatform at least but worth a try for your case as well!)

@Phaestion
Copy link
Contributor

Phaestion commented Dec 30, 2023

@kikermo Seems like this helped me: #649 (For the Compose Multiplatform at least but worth a try for your case as well!)

Thanks for linking the other issue! I'll try this out on my MacBook Pro running Asahi Linux - this has been an issue holding me back from switching to Asahi for my dev work.

I'll report back on my findings.

@Phaestion
Copy link
Contributor

After setting the environmental variable as specified in #649 I get a new error. This is probably an Asahi Linux issue, I'll have to dig a bit deeper I guess. For reference here is the error I'm getting. If anyone has a workaround I'm all ears. 👂

> Task :composeApp:run
Shader compilation error
------------------------
   1	#version 320 es
   2	
   3	precision mediump float;
   4	precision mediump sampler2D;
   5	out mediump vec4 sk_FragColor;
   6	uniform sampler2D uTextureSampler_0_S0;
   7	in highp vec2 vTextureCoords_S0;
   8	flat in highp float vTexIndex_S0;
   9	in mediump vec4 vinColor_S0;
  10	void main() {
  11	    mediump vec4 outputColor_S0 = vinColor_S0;
  12	    mediump vec4 texColor = texture(uTextureSampler_0_S0, vTextureCoords_S0, -0.475).xxxx;
  13	    mediump vec4 outputCoverage_S0 = texColor;
  14	    {
  15	        sk_FragColor = outputColor_S0 * outputCoverage_S0;
  16	    }
  17	}
  18	
Errors:
0:1(10): error: GLSL ES 3.20 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 1.00 ES, and 3.00 ES

@loukwn
Copy link

loukwn commented Jan 16, 2024

@Phaestion I do not know about Asahi Linux but from the error it looks like GLSL needs downgrading (or upgrading) to run this?

@Phaestion
Copy link
Contributor

@loukwn yeah I had a look at this at the time or your comment, but it seemed at the point that Asahi did not support GLSL ES 3.20. Just a few hours ago the the OpenGL used in Asahi was updated to 4.6, which includes ES 3.2!
An engineer working on the Asahi project posted a pretty interesting entry in their blog detailing the work that went into it: https://rosenzweig.io/blog/conformant-gl46-on-the-m1.html

I tested it just a few minutes ago and can confirm that I can now compile and run Compose Multiplatform Desktop apps on Arm64, MacBook Pro running Asahi Linux. I'll be moving my dev environment over to Asahi pretty soon. :)

@loukwn
Copy link

loukwn commented Feb 15, 2024

Damn it all worked in the end! Good one!

@michalguspiel
Copy link

Same issue running on NVIDIA JETSON AGX ORIN :

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000000000, pid=11064, tid=11107
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.10+7 (17.0.10+7) (build 17.0.10+7)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (17.0.10+7, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# C  [libskiko-linux-arm64.so+0x64ae50]  GrGLBuffer::onUpdateData(void const*, unsigned long, unsigned long, bool)+0xc8
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /opt/manpackvision/bin/core.11064)
#
# If you would like to submit a bug report, please visit:
#   https://github.com/adoptium/adoptium-support/issues
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

...

---------------  T H R E A D  ---------------

Current thread (0x0000ffff98e5dd30):  JavaThread "AWT-EventQueue-0" [_thread_in_native, id=11107, stack(0x0000ffff08baf000,0x0000ffff08dad000)]

Stack: [0x0000ffff08baf000,0x0000ffff08dad000],  sp=0x0000ffff08da7ba0,  free space=2018k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libskiko-linux-arm64.so+0x64ae50]  GrGLBuffer::onUpdateData(void const*, unsigned long, unsigned long, bool)+0xc8
C  [libskiko-linux-arm64.so+0x329480]  GrResourceProvider::findOrMakeStaticBuffer(GrGpuBufferType, unsigned long, void const*, skgpu::UniqueKey const&)+0x8c
C  [libskiko-linux-arm64.so+0x37fe24]  skgpu::ganesh::FillRRectOp::(anonymous namespace)::FillRRectOpImpl::onPrepareDraws(GrMeshDrawTarget*)+0x3bc

export MESA_EXTENSION_OVERRIDE="-GL_ARB_invalidate_subdata"
from #649 doesn't help

@dima-avdeev-jb
Copy link
Contributor

@michalguspiel What Compose version are you using?
Can you please create a minimal reproducible samle project?

@michalguspiel
Copy link

I build my project using

compose-compiler = "1.5.6"
compose-plugin = "1.6.0-beta01"

And then I tried another build using

compose-compiler = "1.5.8"
compose-plugin = "1.6.0-rc03"

Should I try using older versions? I'll try to run hello world today.

@dima-avdeev-jb
Copy link
Contributor

@michalguspiel
Thanks, can you please try to run empty project created by wizard https://kmp.jetbrains.com/?
If problem is only in your project, can you please create a minimal reproducible sample and share it with us?

@michalguspiel
Copy link

michalguspiel commented Feb 27, 2024

@dima-avdeev-jb
Hi, I'm facing the same issue when running the Hello World project generated by Wizard. I'm packaging the deb file using docker to achieve cross-compilation for Linux arm64 target.

@michalguspiel
Copy link

@dima-avdeev-jb should I also post this issue in compose-multiplatform project?

@dima-avdeev-jb
Copy link
Contributor

@michalguspiel This Issue is enought. Thanks!

So, on version 1.5.12 created by wizard https://kmp.jetbrains.com/ problem also occurs, correct?

Can you please provide a minimal reproducible sample with Dockerfile?

@michalguspiel
Copy link

Hi, yes the problem occurs also on the project just generated by the wizard.

The issue also occurs if I try to project on NVIDIA JETSON AGX ORIN using ./gradlew composeApp:desktopRun -DmainClass=MainKt

What do you mean minimal reproducible sample? Minimal reproducible sample is the project downloaded from Wizard.

@Phaestion
Copy link
Contributor

Hi, yes the problem occurs also on the project just generated by the wizard.

The issue also occurs if I try to project on NVIDIA JETSON AGX ORIN using ./gradlew composeApp:desktopRun -DmainClass=MainKt

What do you mean minimal reproducible sample? Minimal reproducible sample is the project downloaded from Wizard.

@michalguspiel did you try to add export MESA_EXTENSION_OVERRIDE="-GL_ARB_invalidate_subdata" before your gradle command? This fix the error on M2 MacBook Pro (also an arm64 processor) running Linux.
This was initially posted here: #649 (comment)

@michalguspiel
Copy link

@Phaestion Hi, yes I mentioned it in my first post in this thread: #838 (comment)

@Phaestion
Copy link
Contributor

@michalguspiel ah sorry, I missed that part in your post.

@dima-avdeev-jb
Copy link
Contributor

@michalguspiel

What do you mean minimal reproducible sample? Minimal reproducible sample is the project downloaded from Wizard.

I mean Dockerfile

@michalguspiel
Copy link

@dima-avdeev-jb
Do you mean dockerfile that we use to cross compile the project? I don't find it relevant since the issue persists if project is built on NVIDIA JETSON AGX ORIN machine.

Anyways this is how we compile the project:

FROM --platform=linux/arm64 gradle:7.6.4-jdk17 as BUILD

# Update package lists and install fakeroot
RUN apt-get update && apt-get install -y fakeroot

COPY . /src
WORKDIR /src
RUN ./gradlew packageDeb

# we only need a small image to get the deb package
FROM scratch

# Copy the built artifacts from the previous stage
COPY --from=BUILD /src/composeApp/executables/main/deb /arm64

# Set the working directory for the runtime
WORKDIR /arm64

We execute it with a script:

iname=app_linux_arm64_builder
docker build . -t $iname

# launch container to get build
tc=$(docker create $iname arm64)
mkdir -p ./composeApp/executables/main
docker cp $tc:/arm64 ./composeApp/executables/main/deb
docker rm $tc

echo "Build output in ./composeApp/executables/main/deb"

@sitomani
Copy link

I managed to avoid the crash by executing export SKIKO_RENDER_API=SOFTWARE prior to launching the app with gradle.

This will force the implementation to use software rendering instead of OpenGL on the Nvidia Orin, which will naturally come with a performance penalty, but it is a way to get around the app not launching properly until there is a fix on this either on the skia library, or skiko.

I have also updated my Nvidia Orin to run R35.5, but it does not help with the OpenGL crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants