-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some Data Races #727
Comments
Thanks for this great writeup. I'm convinced that there are tons of race conditions in TestNG; I've found one or two myself. In (1), it sounds like you're describing unsynchronized multi-threaded access to a |
Indeed, thanks for taking the time to write this up, @ThomasKrieger. Would you be willing to send a few pull requests to address those issues? |
Hi,
I want to use testng together with vmlens to test concurrent java programs. Running testng with the following empty testclass:
led to some data races which might lead to unexpected behavior:
Inside org.testng.internal.invokers.InvokedMethodListenerInvoker the unsynchronized map strategies is filled in one of the TestNG threads. I would suggest to fill the map in the main Thread before starting the testng Threads. The fields java/util/HashMap$Node.value@12096,
java/util/HashMap$Node.value@12110, java/util/HashMap.table@12094, java/util/HashMap.table@12104 in the generated trace are all related to this issue.
The Field m_hasTests in the class org.testng.TestNG is written by all TestNG and by the main Thread and read by the main Thread.I would suggest to declare the field as volatile
The Field m_matchingInterface in the enum org.testng.internal.invokers.InvokedMethodListenerSubtype is written in one of the TestNG threads
in the constructor and read by all TestNG threads. I would suggest to make it final.
The field m_numPassed in org.testng.reporters.JUnitXMLReporter is written and read without synchronization in the method:
By the way, the collection m_allTests is a synchronized Collection. I would suggest to synchronize the method onTestSuccess.
You can see the complete trace under: http://traces.vmlens.com/testng/dist/overview.html
Thank you very much
Thomas Krieger
The text was updated successfully, but these errors were encountered: