comparison src/share/vm/prims/jvm.cpp @ 14336:c025990068c4

8028073: race condition in ObjectMonitor implementation causing deadlocks Summary: Move redo of ParkEvent.unpark() after JVMTI_EVENT_MONITOR_WAITED event handler is called. Reviewed-by: dholmes, sspitsyn, dice, acorn
author dcubed
date Mon, 10 Feb 2014 12:48:54 -0800
parents 0f2de9d724a9
children 78fde43dc07d
comparison
equal deleted inserted replaced
14335:4802ce6fbff6 14336:c025990068c4
1 /* 1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
516 JVMWrapper("JVM_MonitorWait"); 516 JVMWrapper("JVM_MonitorWait");
517 Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); 517 Handle obj(THREAD, JNIHandles::resolve_non_null(handle));
518 JavaThreadInObjectWaitState jtiows(thread, ms != 0); 518 JavaThreadInObjectWaitState jtiows(thread, ms != 0);
519 if (JvmtiExport::should_post_monitor_wait()) { 519 if (JvmtiExport::should_post_monitor_wait()) {
520 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms); 520 JvmtiExport::post_monitor_wait((JavaThread *)THREAD, (oop)obj(), ms);
521
522 // The current thread already owns the monitor and it has not yet
523 // been added to the wait queue so the current thread cannot be
524 // made the successor. This means that the JVMTI_EVENT_MONITOR_WAIT
525 // event handler cannot accidentally consume an unpark() meant for
526 // the ParkEvent associated with this ObjectMonitor.
521 } 527 }
522 ObjectSynchronizer::wait(obj, ms, CHECK); 528 ObjectSynchronizer::wait(obj, ms, CHECK);
523 JVM_END 529 JVM_END
524 530
525 531