[PATCH] 8325567: jspawnhelper without args fails with segfault
authorElif Aslan <elifasln@amazon.com>
Fri, 8 Mar 2024 22:09:18 +0000 (22:09 +0000)
committerMatthias Klose <doko@ubuntu.com>
Sat, 29 Jun 2024 07:05:11 +0000 (09:05 +0200)
Origin: commit,262747094670b00ac63463a059074afa9b81d8a4
Bug: https://bugs.openjdk.org/browse/JDK-8325567
Co-authored-by: Vladimir Petko <vpetko@openjdk.org>
Reviewed-by: eastigeevich, rriggs, shade, vpetko
Reviewed-by: eastigeevich, rriggs, shade, vpetko
Gbp-Pq: Name jdk-8325567.patch

src/java.base/unix/native/jspawnhelper/jspawnhelper.c

index 7f86826f077d205cc894f4752a3b3d16fc8f694a..cb660b320b7f029798525d9d7fd01654b03c41bd 100644 (file)
@@ -62,6 +62,7 @@ void shutItDown() {
     fprintf(stdout, "only be run as the result of a call to\n");
     fprintf(stdout, "ProcessBuilder.start() or Runtime.exec() in a java ");
     fprintf(stdout, "application\n");
+    fflush(stdout);
     _exit(1);
 }
 
@@ -142,6 +143,10 @@ int main(int argc, char *argv[]) {
     /* argv[1] contains the fd number to read all the child info */
     int r, fdinr, fdinw, fdout;
 
+    if (argc != 2) {
+        shutItDown();
+    }
+
 #ifdef DEBUG
     jtregSimulateCrash(0, 4);
 #endif