apache / apache/lucene

data races in org.apache.lucene.queryParser.QueryParserTokenManager [LUCENE-5286]

Open
#6,350 1 comment 0 reactions 0 assignees View on GitHub
affects-version:3.6.2 legacy-jira-priority:Major module:core/queryparser type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Hi,

We ran a dynamic detector on Lucene and found quite a number of races in org.apache.lucene.queryParser.QueryParserTokenManager when an instance of this class is shared by multiple threads. Almost all field variables of this class are racey, e.g., curChar, curLexState jjnewStateCnt jjmatchedPos jjmatchedKind.

For example, methods "jjMoveStringLiteralDfa0_3" and "getNextToken" can be executed by different threads at the same time with no synchronization. The read and write to "curChar" at lines 65 and 1174 may corrupt the parser.

63 private int More jjMoveStringLiteralDfa0_3()
64 {
65 switch(curChar)
66 {

1164public Token More getNextToken()
1165{
1166 Token matchedToken;
1167 int curPos = 0;
1168
1169 EOFLoop :
1170 for (;;)
1171 {
1172 try
1173 {
1174 curChar = input_stream.BeginToken();
1175 }

---
Migrated from [LUCENE-5286](https://issues.apache.org/jira/browse/LUCENE-5286) by Jeff Huang

Contributor guide

Open the contributing guide

Research direction

Start with org.apache.lucene.queryParser.QueryParserTokenManager, especially getNextToken and jjMoveStringLiteralDfa0_3, and inspect how their shared fields and input_stream are used across threads. Determine how concurrent use should be made safe and define completion around preventing corruption when one instance is shared by multiple threads.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.