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

info.updateTerminalSize() can crash on MacOS Ventura #86

Open
corbym opened this issue Jan 31, 2023 · 13 comments
Open

info.updateTerminalSize() can crash on MacOS Ventura #86

corbym opened this issue Jan 31, 2023 · 13 comments

Comments

@corbym
Copy link

corbym commented Jan 31, 2023

Firstly let me thank you for this amazing lib AND cliktcommand. They are super useful :)

However, apart from not really working (as you can see from the video, all the tables get squashed to nothing), the jvm updateTerminalSize function causes the JVM to crash on MacOs Ventura:

hs_err_pid22892.log

replay_pid77535.log

Crash log on console out:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000010469021c, pid=77535, tid=23299
#
# JRE version: OpenJDK Runtime Environment GraalVM CE 22.3.0 (17.0.5+8) (build 17.0.5+8-jvmci-22.3-b08)
# Java VM: OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (17.0.5+8-jvmci-22.3-b08, mixed mode, sharing, tiered, jvmci, jvmci compiler, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# V  [libjvm.dylib+0x75021c]  MethodMatcher::matches(methodHandle const&) const+0x44
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/mattcorby-eaglen/repos/binder/applications/connect-cli/hs_err_pid77535.log
> #
# Compiler replay data is saved as:
# /[redacted]/replay_pid77535.log
sigsegv.mov

All this command I'm running is calling the updateTerminalSize function in a CliktCommand underneath. I'm adapting the mordant terminal using the interfaces provided for Clikt, if you are wondering, and everything works fine in a linux docker environment.

Edit:

> java -version
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 17.0.5+8-jvmci-22.3-b08, mixed mode, sharing)

Second edit: added console crash message for GraalVm and replay log

@ajalt
Copy link
Owner

ajalt commented Jan 31, 2023

I can't really read the text in that video. Can you post the crash text and the code that reproduces this?

It's strange that it works for a while. This is tricky since I don't have a mac machine to test on, and this doesn't look like I'll be able to reproduce it in a unit test on CI.

@corbym
Copy link
Author

corbym commented Jan 31, 2023

Hey

The same crash text is in the hs_err log attached I think.

If that doesn't help I'll post it when I get back to my laptop tomorrow 👍

@ajalt
Copy link
Owner

ajalt commented Jan 31, 2023

Ah, thanks, I missed that in the original post.

Does this crash only occur under Graal? Does it work on a regular JVM?

@corbym
Copy link
Author

corbym commented Jan 31, 2023

On the HotSpot JVM the crash is as follows:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000014754ac14, pid=75088, tid=5635
#
# JRE version: Java(TM) SE Runtime Environment (17.0.6+9) (build 17.0.6+9-LTS-190)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (17.0.6+9-LTS-190, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# j  jdk.proxy2.$Proxy2.ioctl(ILcom/sun/jna/NativeLong;Lcom/github/ajalt/mordant/internal/MacosLibC$winsize;)I+27 jdk.proxy2
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# [redacted]/hs_err_pid75088.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp

HotSpot hs_err_pid
hs_err_pid75088.log

java details:

> java -version
java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)

@corbym
Copy link
Author

corbym commented Feb 1, 2023

Possibly related? jline/jline3#688 - there are several linked issues that might be worth reading about.

I do use JLine (v3.22.0), but not to discover or update anything regarding the size of the terminal.

@ajalt
Copy link
Owner

ajalt commented Feb 3, 2023

@corbym great find! I implemented the ioctl from the linked issue in #87. Let me know if that fixes the crash.

@nfsantos
Copy link

Hello. I'm having a problem that may be related. I'm on M1 MacBook Pro running Ventura. Calling updateTerminalSize does not crash in my machine but instead fails to detect the size of the terminal (it returns false). The size is left to 79 x 24, which makes all the tables and formatting in general too small. This problem only occurs with version 2.0.0-beta10 and 2.0.0-beta11. With 2.0.0-beta9 and earlier, the detection of the terminal size works fine.

Do you think it is related to this issue or is it a separate issue?

@ajalt
Copy link
Owner

ajalt commented Feb 10, 2023

@nfsantos probably the same issue. Can you try the branch on #87 to see if it fixes your issue?

@nfsantos
Copy link

Sure, I can try. How should I do to try that branch? Is there a binary somewhere for that branch or do I have to build it locally?

@ajalt
Copy link
Owner

ajalt commented Feb 10, 2023

I just merged the PR, so you can use the latest snapshot once it finishes building.

@nfsantos
Copy link

I have tried with the latest snapshot release and it still failed to detect the terminal size. It fails in the same way as with 2.0.0-beta11, that is, updateTerminalSize() returns false. Shall I open a new issue? What additional information do you need to try to debug the issue?

$ ./gradew dependencies:
...
+--- com.github.ajalt.mordant:mordant:2.0.0-beta11.72-SNAPSHOT
|    \--- com.github.ajalt.mordant:mordant-jvm:2.0.0-beta11.72-SNAPSHOT
|         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0 (*)
|         +--- com.github.ajalt.colormath:colormath:3.2.1
|         |    \--- com.github.ajalt.colormath:colormath-jvm:3.2.1
|         |         +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10 -> 1.8.0 (*)
|         |         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10 -> 1.8.0
|         +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.8.0
|         +--- org.jetbrains:markdown:0.3.6
|         |    \--- org.jetbrains:markdown-jvm:0.3.6
|         |         +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.5.31 -> 1.8.0
|         |         \--- org.jetbrains.kotlin:kotlin-stdlib:1.5.31 -> 1.8.0 (*)
|         \--- net.java.dev.jna:jna:5.12.1

@corbym
Copy link
Author

corbym commented Feb 13, 2023

@ajalt Naive testing suggests that this has worked to fix the crash. However, changing the term size doesn't affect the numbers in the column. At least the size does not shrink to nothing any more :)

Screen.Recording.2023-02-13.at.16.49.57.mov

@ajalt
Copy link
Owner

ajalt commented Mar 25, 2023

I just released a new version of Mordant that reverts to the old detectTerminalSize implementation for now. I'm leaving this issue open until we can figure out how to get it working with jna. Let me know if it still doesn't work.

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

3 participants