Summary: | [1.5][compiler] Enum / Switch method is not initialized in a thread safe way | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Tim Hanson <thanson> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | daniel_megert, sta_larsen | ||||
Version: | 3.1 | ||||||
Target Milestone: | 3.1 RC3 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
See Also: | https://bugs.eclipse.org/bugs/show_bug.cgi?id=544521 | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Tim Hanson
2005-06-09 19:46:13 EDT
This would be a good candidate for RC3. I also found a bug when the generated method is over 65K. +1 for RC3 Dani - could you cast a vote for this ? We need to ensure we init enumerations in a thread safe way. Agree. + 1 for 3.1 RC3. Tim, could you please let me know what VM you are using? I could not reproduce the failure, but I agree that it is possible to fail. I won't fix it by introducing an anonymous type. I will keep using the synthetic method that we have, but instead of setting the field immediately, I will use a local variable. This should prevent acccessing the array while it is being filled with the right values. This won't prevent multiple initialization of the array, but since all initialization leads to the same value, we will simply persist one of them. I am using the Sun VM 1.5.0_03. I think I'm probably more likely to see the failure because my machine has two processors. Would you mind then to try a patch once I fixed this issue? Of course. Created attachment 22950 [details]
Proposed fix
This should make the initialization of the table thread-safe.
Could you please apply the patch and let me know if it works?
Thank you.
It passed on my machine. Could you easily reproduce the failure before? If yes, I would close as FIXED. Unfortunately I don't have a good regression test. For me the failure was 100% reproducible. I just retried & it failed 5 times in 5 tries. The fix succeeded 5 times in a row. Thank you. Fixed and released in HEAD. Will try to get a regressio test that is not timing-dependant. Changes located in CodeStream. I use a local variable to store the array initialization and I assign it to the field just before the method returns. I just noticed that the switch table is final. Is that your intention? I don't believe that is correct since it is not assigned in the static initializer, and it can potentially be assigned multiple times. The VM spec is strangely silent on the issue, and the Sun VM accepts it, but JRockit doesn't like that. final has been removed. Released in HEAD. Verified using build N20050616-0010 + JDT Core HEAD. |