mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8222534: VerifyBeforeExit is not honored when System.exit is called
Reviewed-by: coleenp, rehn
This commit is contained in:
parent
4f02d011b0
commit
e0dcd3200a
2 changed files with 40 additions and 2 deletions
|
@ -526,11 +526,31 @@ void vm_exit(int code) {
|
|||
vm_direct_exit(code);
|
||||
}
|
||||
|
||||
// We'd like to add an entry to the XML log to show that the VM is
|
||||
// terminating, but we can't safely do that here. The logic to make
|
||||
// XML termination logging safe is tied to the termination of the
|
||||
// VMThread, and it doesn't terminate on this exit path. See 8222534.
|
||||
|
||||
if (VMThread::vm_thread() != NULL) {
|
||||
if (thread->is_Java_thread()) {
|
||||
// We must be "in_vm" for the code below to work correctly.
|
||||
// Historically there must have been some exit path for which
|
||||
// that was not the case and so we set it explicitly - even
|
||||
// though we no longer know what that path may be.
|
||||
((JavaThread*)thread)->set_thread_state(_thread_in_vm);
|
||||
}
|
||||
|
||||
// Fire off a VM_Exit operation to bring VM to a safepoint and exit
|
||||
VM_Exit op(code);
|
||||
if (thread->is_Java_thread())
|
||||
((JavaThread*)thread)->set_thread_state(_thread_in_vm);
|
||||
|
||||
// 4945125 The vm thread comes to a safepoint during exit.
|
||||
// GC vm_operations can get caught at the safepoint, and the
|
||||
// heap is unparseable if they are caught. Grab the Heap_lock
|
||||
// to prevent this. The GC vm_operations will not be able to
|
||||
// queue until after we release it, but we never do that as we
|
||||
// are terminating the VM process.
|
||||
MutexLocker ml(Heap_lock);
|
||||
|
||||
VMThread::execute(&op);
|
||||
// should never reach here; but in case something wrong with VM Thread.
|
||||
vm_direct_exit(code);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue