Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 700 invoked from network); 14 Nov 2007 09:51:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Nov 2007 09:51:04 -0000 Received: (qmail 49961 invoked by uid 500); 14 Nov 2007 09:50:52 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 49932 invoked by uid 500); 14 Nov 2007 09:50:51 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 49908 invoked by uid 99); 14 Nov 2007 09:50:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Nov 2007 01:50:51 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Nov 2007 09:51:03 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 1C524714209 for ; Wed, 14 Nov 2007 01:50:43 -0800 (PST) Message-ID: <23785715.1195033843105.JavaMail.jira@brutus> Date: Wed, 14 Nov 2007 01:50:43 -0800 (PST) From: "Pavel Rebriy (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-3267) [drlvm][thread] Thread.stop() implementation is broken In-Reply-To: <23379805.1172685237090.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-3267?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Pavel Rebriy updated HARMONY-3267: ---------------------------------- Attachment: H3267.patch The patch to fix the issue. With the patch DRLVM has got results the same as RI. > [drlvm][thread] Thread.stop() implementation is broken > ------------------------------------------------------ > > Key: HARMONY-3267 > URL: https://issues.apache.org/jira/browse/HARMONY-3267 > Project: Harmony > Issue Type: Bug > Components: DRLVM > Reporter: Salikh Zakirov > Assignee: weldon washburn > Priority: Minor > Attachments: H3267.patch, H3267.patch, Limited-Thread.stop-fix-for-stopping-waiting-threads.patch, StopBlocked.java, StopBlockedOnMonitor.java, StopWaiting.java > > > The current implementation of Thread.stop() in DRLVM is completely broken. > The attached tests StopWaiting.java and StopBlocked.java demonstrate current incorrect behaviour: > DRLVM can't stop the thread which is blocked either waiting or entering monitor. > The waiting case can be fixed by checking the thread state, setting some checked status and waking thread up, like the patch below. > However, the blocking case cannot fixed in this way, as we have no easy way to wake up a thread which is blocked on a pthread_mutex_lock or EnterCriticalSection OS call. > It looks like a correct implementation of stopping blocked thread will require either pthread_kill() or SuspendThread() and modifying thread context (like throwing an exception or longjmp). > Both tests pass on competition VMs (Sun, Bea, Ibm). > ----8<----- > A limited fix for a waiting case only. > --- vm/thread/src/thread_java_basic.c > +++ vm/thread/src/thread_java_basic.c > @@ -416,7 +416,23 @@ void stop_callback(void) { > tm_native_thread->suspend_request = 0; > hysem_post(tm_native_thread->resume_event); > > + // Does not return if the exception could be thrown straight away > jthread_throw_exception_object(excn); > + > + // getting here means top stack frame is non-unwindable. > + > + if (tm_native_thread->state & > + (TM_THREAD_STATE_SLEEPING | TM_THREAD_STATE_WAITING_WITH_TIMEOUT > + | TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT > + | TM_THREAD_STATE_WAITING_INDEFINITELY | TM_THREAD_STATE_PARKED)) { > + // This is needed for correct stopping of a thread blocked on monitor_wait. > + // The thread needs some flag to exit its waiting loop. > + // We piggy-back on interrupted status. A correct exception from TLS > + // will be thrown because the check of exception status on leaving > + // JNI frame comes before checking return status in Object.wait(). > + // Interrupted status will be cleared by > + hythread_interrupt(tm_native_thread); > + } > } > > /** -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.