[
https://issues.apache.org/jira/browse/LUCENE-4987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13651882#comment-13651882
]
Dawid Weiss commented on LUCENE-4987:
-------------------------------------
I think I found the reason. J9 seems to be optimizing away the following code:
{code}
@Override public synchronized void handleEvent(Object event)
throws InvocationTargetException {
super.handleEvent(event);
}
{code}
this method is removed entirely as the stack trace from the 'wtf' exception
shows:
{code}
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
at java.lang.reflect.Method.invoke(Method.java:613)
at
com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
at
com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at
com.carrotsearch.ant.tasks.junit4.it.TestJ9SanityCheck$2.call(TestJ9SanityCheck.java:75)
at
com.carrotsearch.ant.tasks.junit4.it.TestJ9SanityCheck$2.call(TestJ9SanityCheck.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:345)
at java.util.concurrent.FutureTask.run(FutureTask.java:177)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1121)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
at java.lang.Thread.run(Thread.java:777)
Caused by: java.lang.RuntimeException: Wtf? two threads in a handler:
Thread[pool-100-thread-1,5,TGRP-TestJ9SanityCheck] and
Thread[pool-100-thread-2,5,TGRP-TestJ9SanityCheck]
at
com.carrotsearch.ant.tasks.junit4.it.TestJ9SanityCheck$1.onSlaveIdle(TestJ9SanityCheck.java:52)
... 14 more
{code}
The eventhandler type is definitely SynchronizedEventHandler and on Hotspot you
do get a synchronized indirection layer (a call under a synchronized monitor),
whereas on J9 this becomes a full race condition.
> Test framework may fail internally under J9 (some serious JVM
> exclusive-section issue).
> ---------------------------------------------------------------------------------------
>
> Key: LUCENE-4987
> URL: https://issues.apache.org/jira/browse/LUCENE-4987
> Project: Lucene - Core
> Issue Type: Bug
> Reporter: Dawid Weiss
> Assignee: Dawid Weiss
> Priority: Minor
> Attachments: j9.zip
>
>
> This was reported by Shai. The runner failed with an exception:
> {code}
> [junit4:junit4] Caused by: java.util.NoSuchElementException
> [junit4:junit4] at
> java.util.ArrayDeque.removeFirst(ArrayDeque.java:289)
> [junit4:junit4] at java.util.ArrayDeque.pop(ArrayDeque.java:518)
> [junit4:junit4] at
> com.carrotsearch.ant.tasks.junit4.JUnit4$1.onSlaveIdle(JUnit4.java:809)
> [junit4:junit4] ... 17 more
> {code}
> The problem is that this is impossible because the code around
> JUnit4.java:809 looks like this:
> {code}
> final Deque<String> stealingQueue = new ArrayDeque<String>(...);
> aggregatedBus.register(new Object() {
> @Subscribe
> public void onSlaveIdle(SlaveIdle slave) {
> if (stealingQueue.isEmpty()) {
> ...
> } else {
> String suiteName = stealingQueue.pop();
> ...
> }
> }
> });
> {code}
> and the contract on Guava's EventBus states that:
> {code}
> * <p>The EventBus guarantees that it will not call a handler method from
> * multiple threads simultaneously, unless the method explicitly allows it by
> * bearing the {@link AllowConcurrentEvents} annotation. If this annotation
> is
> * not present, handler methods need not worry about being reentrant, unless
> * also called from outside the EventBus
> {code}
> I wrote a simple snippet of code that does it in a loop and indeed, two
> threads can appear in the critical section at once. This is not reproducible
> on Hotspot and only appears to be the problem on J9/1.7/Windows (J9 1.6 works
> fine).
> I'll provide a workaround in the runner (an explicit monitor seems to be
> working) but this is some serious J9 issue.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]