octave java error: pthread_create failed

Bug #1866453 reported by ianmacs
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
octave (Ubuntu)
New
Undecided
Unassigned

Bug Description

While testing (the not-yet-released) ubuntu 20.04 on amd64:

Packages and versions:
octave 5.2.0-1
default-jre-headless 2:1.11-72
openjdk-11-jre-headless 11.0.6+10-2ubuntu2

Steps to reproduce:

In octave, use java to execute a child process:

runtime = javaMethod('getRuntime','java.lang.Runtime')
runtime.exec('/usr/bin/touch /tmp/testfile2');

Expected behaviour:
The child process is executed and octave reports no error.

Observed behaviour:
The child process is executed, but octave reports an error:

[13.203s][warning][os,thread] Failed to start thread - pthread_create failed (EINVAL) for attributes: stacksize: 136k, guardsize: 0k, detached.
error: [java] java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

This error interrupts e.g. execution of octave functions when runtime.exec is used inside them.

The same error did not happen in ubuntu 18.04.

I can work around it by replacing openjdk11 with openjdk8 and pointing octave to it with symlinks:
apt-get install openjdk-8-jdk-headless
apt-get remove openjdk-11-jre-headless
ln -s java-8-openjdk-amd64/ /usr/lib/jvm/default-java
ln -s ../jre/lib/amd64/server/ /usr/lib/jvm/java-8-openjdk-amd64/lib/server

octave will then use openjdk8 where the error will not occur.

Revision history for this message
ianmacs (ianmacs2018) wrote :

I should add 2 more observations:

1)

When using openjdk8, the same method causes the printing of this text
Exception: java.lang.StackOverflowError thrown from the UncaughtExceptionHandler in thread "process reaper"
But this does not interrupt the execution of the current octave function (and the child process is executed as expected).

2)
Executing the same sequence in a simple java program with openjdk11 does not exhibit the same error: This programm

public class A {
    public static void main(String[] args) {
        java.lang.Runtime runtime = java.lang.Runtime.getRuntime();
        try {
            runtime.exec("/usr/bin/touch /tmp/testfile3");
            System.out.println("Success");
        } catch (java.lang.Exception e) {
            System.out.println("Error");
        }
    }
}

compiled with javac 11.0.6 prints "Success", not "Error", and the child process is executed.

Revision history for this message
ianmacs (ianmacs2018) wrote :

This bug can be fixed in Ubuntu 20.04 by creating a file named /usr/share/octave/5.2.0/m/java/java.opts with the following contents:

-Djdk.lang.processReaperUseDefaultStackSize=true

Revision history for this message
ianmacs (ianmacs2018) wrote :

BTW: Current ubuntu versions (21.04, 21.10) install newer octave packages and are not affected.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.