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

NPE on Windows using "Git for Windows" (MINGW) #387

Closed
baumato opened this issue Mar 29, 2021 · 5 comments
Closed

NPE on Windows using "Git for Windows" (MINGW) #387

baumato opened this issue Mar 29, 2021 · 5 comments
Milestone

Comments

@baumato
Copy link

baumato commented Mar 29, 2021

I use Git for Windows (https://git-scm.com/download/win). When executing
mvnd --version
nothing happens until I press Enter for the second time. Then the result is:

$ mvnd --version
Exception in thread "Thread-0" java.lang.NullPointerException
        at org.mvndaemon.mvnd.common.logging.TerminalOutput.readInputLoop(TerminalOutput.java:451)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
mvnd native client 0.4.3-windows-amd64 (e20989ddd440928f392f839c282c6ef196107404)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.ExecPty
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Apps\mvnd\mvn
Java version: 1.8.0_261, vendor: Oracle Corporation, runtime: C:\Apps\jdk8\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Since Git for Windows uses MINGW
$ env | grep MSYSTEM
MSYSTEM_CARCH=x86_64
MSYSTEM_CHOST=x86_64-w64-mingw32
MSYSTEM_PREFIX=/mingw64
MSYSTEM=MINGW64
JLine provides a PosixSysTerminal. May this be related?

Update:
When I override the environment variable MSYSTEM, I get following output:

$ old=$MSYSTEM; echo old=$old; MSYSTEM=""; mvnd --version; MSYSTEM=$old; echo $MSYSTEM
old=MINGW64
Mar 29, 2021 3:41:54 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
mvnd native client 0.4.3-windows-amd64 (e20989ddd440928f392f839c282c6ef196107404)
Terminal: org.jline.terminal.impl.DumbTerminal
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\hlag\Apps\FIDE\mvnd\mvn
Java version: 1.8.0_261, vendor: Oracle Corporation, runtime: C:\hlag\Apps\FIDE\jdk8\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
MINGW64

This works, but I cannot enjoy the nice ouput that is usually available.

@baumato baumato changed the title maven daemon shows NullPointerException on Windows using "Git for Windows" NPE on Windows using "Git for Windows" (MINGW) Mar 29, 2021
@baumato
Copy link
Author

baumato commented Mar 31, 2021

When using
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.ExecPty
then the call of read(10) within the readInputLoop in TerminalOutput is blocking forever. Reading the documentation of the method, this should not be the case.

   void readInputLoop() {
        try {
            while (!closing) {
                if (readInput.readLock().tryLock(10, TimeUnit.MILLISECONDS)) {
                    int c = terminal.reader().read(10);
                    if (c == -1) {
                        break;
                    }
                    if (c == KEY_PLUS || c == KEY_MINUS || c == KEY_CTRL_L || c == KEY_CTRL_M || c == KEY_CTRL_B) {
                        daemonReceive.accept(Message.keyboardInput((char) c));
                    }
                    readInput.readLock().unlock();
                }
            }
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        } catch (InterruptedIOException e) {
            Thread.currentThread().interrupt();
        } catch (IOException e) {
            this.exception = e;
        }
    }

Analysis is ongoing!

@baumato
Copy link
Author

baumato commented Mar 31, 2021

Cannot figure it out. Directly after starting mvnd the program hangs. Thread dump is:

3XMTHREADINFO3           Java callstack:
4XESTACKTRACE                at java/io/FileInputStream.readBytes(Native Method)
4XESTACKTRACE                at java/io/FileInputStream.read(FileInputStream.java:279)
4XESTACKTRACE                at java/io/BufferedInputStream.fill(BufferedInputStream.java:252)
4XESTACKTRACE                at java/io/BufferedInputStream.read(BufferedInputStream.java:271)
5XESTACKTRACE                   (entered lock: java/io/BufferedInputStream@0x00000007FFEA64F8, entry count: 1)
4XESTACKTRACE                at org/jline/utils/ExecHelper.waitAndCapture(ExecHelper.java:58)
4XESTACKTRACE                at org/jline/utils/ExecHelper.exec(ExecHelper.java:36)
4XESTACKTRACE                at org/jline/terminal/impl/ExecPty.doGetConfig(ExecPty.java:175)
4XESTACKTRACE                at org/jline/terminal/impl/ExecPty.getSize(ExecPty.java:169)
4XESTACKTRACE                at org/jline/terminal/impl/AbstractPosixTerminal.getSize(AbstractPosixTerminal.java:60)
4XESTACKTRACE                at org/mvndaemon/mvnd/common/logging/TerminalOutput.update(TerminalOutput.java:506)
4XESTACKTRACE                at org/mvndaemon/mvnd/common/logging/TerminalOutput.accept(TerminalOutput.java:191)
4XESTACKTRACE                at org/mvndaemon/mvnd/client/DefaultClient.execute(DefaultClient.java:176)
4XESTACKTRACE                at org/mvndaemon/mvnd/client/DefaultClient.main(DefaultClient.java:112)
3XMTHREADINFO3           Java callstack:
4XESTACKTRACE                at java/io/FileInputStream.read0(Native Method)
4XESTACKTRACE                at java/io/FileInputStream.read(FileInputStream.java:231)
4XESTACKTRACE                at org/jline/terminal/impl/AbstractPty$PtyInputStream.read(AbstractPty.java:73)
4XESTACKTRACE                at org/jline/utils/NonBlockingInputStream.read(NonBlockingInputStream.java:62)
4XESTACKTRACE                at org/jline/utils/NonBlocking$NonBlockingInputStreamReader.read(NonBlocking.java:168)
4XESTACKTRACE                at org/jline/utils/NonBlockingReader.read(NonBlockingReader.java:57)
4XESTACKTRACE                at org/mvndaemon/mvnd/common/logging/TerminalOutput.readInputLoop(TerminalOutput.java:446)
4XESTACKTRACE                at org/mvndaemon/mvnd/common/logging/TerminalOutput$$Lambda$84/0000000000000000.run(Bytecode PC:4)
4XESTACKTRACE                at java/lang/Thread.run(Thread.java:834)

There are two places where read from terminal happens and it seems, this is not supported by the PosixSysTerminal. It seems, we need to stick to the dump terminal.

@ghost
Copy link

ghost commented Apr 1, 2021

Same problem here with WSL 1:

$ mvnd --status
Exception in thread "Thread-1" java.lang.NullPointerException
        at org.mvndaemon.mvnd.common.logging.TerminalOutput.readInputLoop(TerminalOutput.java:451)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
      ID      PID   Port   Status    RSS            Last activity  Java home
dc5f4fcc      158  62872     Idle   792m  2021-04-01T13:55:33.572  /mnt/c/Dev/Tools/graalvm-ce-java11-linux-21.0.0.2

@gnodet
Copy link
Contributor

gnodet commented May 6, 2021

Same problem here with WSL 1:

$ mvnd --status
Exception in thread "Thread-1" java.lang.NullPointerException
        at org.mvndaemon.mvnd.common.logging.TerminalOutput.readInputLoop(TerminalOutput.java:451)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
      ID      PID   Port   Status    RSS            Last activity  Java home
dc5f4fcc      158  62872     Idle   792m  2021-04-01T13:55:33.572  /mnt/c/Dev/Tools/graalvm-ce-java11-linux-21.0.0.2

@Axblu Which mvnd binary are you using, the windows or the linux one ? Can you paste the output of mvnd --version ? It seems to work for me with the windows executable on WSL 1.

@baumato I've been able to reproduce the problem with MINGW. It seems setting the console into raw mode using stty does not really work, that seems to be the reason why the call to read(10) only returns when the enter key is pressed.

@gnodet gnodet closed this as completed in 9bcee29 May 19, 2021
@gnodet gnodet added this to the 0.5.0 milestone May 19, 2021
@ghost
Copy link

ghost commented May 19, 2021

@gnodet Using the Linux binary:

$ file `which mvnd`
/home/belu/.sdkman/candidates/mvnd/current/bin/mvnd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=2b4ca6fd73459d0c580838d37f4e374c53d9ef44, with debug_info, not stripped

And the following version:

mvnd native client 0.4.3-linux-amd64 (e20989ddd440928f392f839c282c6ef196107404)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.linux.LinuxNativePty
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/belu/.sdkman/candidates/mvnd/0.4.3/mvn
Java version: 11.0.10, vendor: GraalVM Community, runtime: /mnt/c/Dev/Tools/graalvm-ce-java11-linux-21.0.0.2
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-17763-microsoft", arch: "amd64", family: "unix"
Exception in thread "Thread-1" java.lang.RuntimeException: java.lang.InterruptedException
        at org.mvndaemon.mvnd.client.DaemonClientConnection.enqueue(DaemonClientConnection.java:141)
        at org.mvndaemon.mvnd.common.logging.TerminalOutput.readInputLoop(TerminalOutput.java:451)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.InterruptedException
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(AbstractQueuedSynchronizer.java:1261)
        at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(ReentrantLock.java:317)
        at java.util.concurrent.ArrayBlockingQueue.put(ArrayBlockingQueue.java:364)
        at org.mvndaemon.mvnd.client.DaemonClientConnection.enqueue(DaemonClientConnection.java:139)
        ... 4 more

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

2 participants