On Wed, 10 Jun 2026 16:15:08 GMT, Andy Goryachev <[email protected]> wrote:

>> This PR fixes a long-standing intermittent build failure on macOS (although 
>> it could have hit any platform, we never saw it on Windows or Linux). The 
>> problem was a race condition in the custom Groovy CCTask used by gradle to 
>> compile native C / C++ code. A set of C/C++ command line options is passed 
>> in to the custom CCTask and in the case of C++ files, mutated (to remove an 
>> unwanted option). The bug is that the original list, which is passed in to 
>> each invocation of CCTask is mutated rather than making a copy and mutating 
>> that. When compilation tasks are run in parallel (which they are by 
>> default), this can lead to the exception if one thread mutates the list 
>> while another thread reads the list.
>> 
>> Even without the concurrency error, mutating the input list of options 
>> directly is wrong, and should never have been done. The fix is to make a 
>> copy of the input args and operate on the copy.
>> 
>> I was able to provoke this bug on my local system by creating a few extra 
>> dummy files in the native-font directory and then running `gradle 
>> cleanNativeFont; gradle :graphics:ccMacFont` in a loop. Without the fix it 
>> fails for me after about 10-30 iterations. With the fix, I've run > 100 and 
>> still running.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> buildSrc/src/main/groovy/com/sun/javafx/gradle/CCTask.groovy line 68:
> 
>> 66:                 // A little hack. Only use the -std=c99 flag if 
>> compiling .c or .m
>> 67:                 if (sourceFile.name.endsWith(".cpp") || 
>> sourceFile.name.endsWith(".cc") || sourceFile.name.endsWith(".mm")) {
>> 68:                     def stripped = new ArrayList<String>(params);
> 
> pre-existing: the comment in L66 does not exactly correspond to code...

Right. I decided to leave it, since it's conceptually accurate, if imprecise.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2186#discussion_r3390059784

Reply via email to