[jboss-jira] [JBoss JIRA] (DROOLS-635) NPE thrown intermittently in multi-threading environment
Mario Fusco (JIRA)
issues at jboss.org
Mon Oct 20 04:18:35 EDT 2014
[ https://issues.jboss.org/browse/DROOLS-635?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13013252#comment-13013252 ]
Mario Fusco commented on DROOLS-635:
------------------------------------
As the comment to that remove method says: "we assume that this rightTuple is contained in this hash table" and this means that a null check there shouldn't be necessary. More important we actually want that method to fail fast if we try to remove a tuple that is not in that memory and for this reason we intentionally avoid to perform any null check there.
Now I see that method is not thread-safe and then I understand how it could fail if executed by multiple threads in parallel. What I don't understand is under which cicumstances this race condition happens. In other terms the problem is not in the missing null check but in a missing synchronization. Unfortunately at the moment I am not able to reproduce this condition and then fix this bug. If you have a test case reproducing this problem can you please attach it to this ticket? Thanks.
> NPE thrown intermittently in multi-threading environment
> --------------------------------------------------------
>
> Key: DROOLS-635
> URL: https://issues.jboss.org/browse/DROOLS-635
> Project: Drools
> Issue Type: Bug
> Affects Versions: 6.1.0.Final, 6.2.0.Beta1, 6.2.0.CR1
> Reporter: John Le
> Assignee: Mario Fusco
>
> Below is the stacktrace for the NPE, it appears to be an issue when accumulate function is called under multi-threading condition. Please look at the remove function in the RightTupleIndexHashTable.java file. The remove function does not appear to have proper null checking around the "current" object.
> public void remove(final RightTuple rightTuple) {
> RightTupleList memory = rightTuple.getMemory();
> memory.remove( rightTuple );
> this.factSize--;
> if ( memory.first == null ) {
> final int index = indexOf( memory.hashCode(),
> this.table.length );
> RightTupleList previous = null;
> RightTupleList current = (RightTupleList) this.table[index];
> while ( current != memory ) {
> previous = current;
> current = (RightTupleList) current.getNext();
> }
> if ( previous != null ) {
> previous.next = current.next;
> } else {
> this.table[index] = current.next;
> }
> this.size--;
> }
> rightTuple.clear();
> }
> Stacktrace:
> java.lang.NullPointerException
> org.drools.core.util.index.RightTupleIndexHashTable.remove(RightTupleIndexHashTable.java:389)
> org.drools.core.phreak.RuleNetworkEvaluator.doUpdatesReorderRightMemory(RuleNetworkEvaluator.java:855)
> org.drools.core.phreak.PhreakJoinNode.doNode(PhreakJoinNode.java:43)
> org.drools.core.phreak.RuleNetworkEvaluator.switchOnDoBetaNode(RuleNetworkEvaluator.java:548)
> org.drools.core.phreak.RuleNetworkEvaluator.evalBetaNode(RuleNetworkEvaluator.java:534)
> org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:334)
> org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:161)
> org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:116)
> org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:230)
> org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:103)
> org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:988)
> org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1274)
> org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1284)
> org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1257)
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
More information about the jboss-jira
mailing list