Changeset 341


Ignore:
Timestamp:
Mar 8, 2012, 1:46:46 PM (9 years ago)
Author:
dmik
Message:

jdk: Create JVM on main thread in Java executables on OS/2.

This fixes hangs at crashes when the Java process is killed
externally by Ctrl-C or by a kill signal (#33 and #159).

Location:
trunk/openjdk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/hotspot/src/share/tools/launcher/java.c

    r309 r341  
    7979#include <string.h>
    8080
     81#ifdef __OS2__
     82#include <float.h> // for _control87
     83#endif
     84
    8185#include <jni.h>
    8286#include <jvm.h>
     
    387391      args.ifn = ifn;
    388392
     393#ifdef __OS2__
     394      // On OS/2, both Ctrl-C and process termination handlers (including DLL
     395      // uninitialization code) are always called on thread 1. If we fire off
     396      // a new thread here and create the JVM on it (as other platfroms do),
     397      // thread 1 will be not known to the JVM and this can cause various
     398      // nexpected side-effects like hangs and crashes at Java process
     399      // termination (see #33 and #159 for details). For this reason, we instead
     400      // create the JVM right on thread 1.
     401
     402      // disable FPU exceptions (taken from jdk/src/windows/hpi/src/system_md.c)
     403      _control87(MCW_EM | RC_NEAR | PC_53, MCW_EM | MCW_RC | MCW_PC);
     404
     405      return JavaMain(&args);
     406#else
    389407      return ContinueInNewThread(JavaMain, threadStackSize, (void*)&args);
     408#endif
    390409    }
    391410}
  • trunk/openjdk/jdk/src/share/bin/java.c

    r333 r341  
    5858#include <string.h>
    5959
     60#ifdef __OS2__
     61#include <float.h> // for _control87
     62#endif
     63
    6064#include <jni.h>
    6165#include <jvm.h>
     
    368372      args.ifn = ifn;
    369373
     374#ifdef __OS2__
     375      // On OS/2, both Ctrl-C and process termination handlers (including DLL
     376      // uninitialization code) are always called on thread 1. If we fire off
     377      // a new thread here and create the JVM on it (as other platfroms do),
     378      // thread 1 will be not known to the JVM and this can cause various
     379      // nexpected side-effects like hangs and crashes at Java process
     380      // termination (see #33 and #159 for details). For this reason, we instead
     381      // create the JVM right on thread 1.
     382
     383      // disable FPU exceptions (taken from jdk/src/windows/hpi/src/system_md.c)
     384      _control87(MCW_EM | RC_NEAR | PC_53, MCW_EM | MCW_RC | MCW_PC);
     385
     386      return JavaMain(&args);
     387#else
    370388      return ContinueInNewThread(JavaMain, threadStackSize, (void*)&args, ret);
     389#endif
    371390    }
    372391}
Note: See TracChangeset for help on using the changeset viewer.