rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Likely race conditions when core library files are modified

Open cristianoc opened this issue 3 years ago • 10 comments
trafficstars

See for example https://github.com/rescript-lang/rescript-compiler/pull/5539#issuecomment-1180325550

Commands behaving non-deterministically, i.e. run it again and you might get a different result: 1 ./scripts/ninja.js clean, config , build 2 node scripts/install -force-lib-rebuild

It could be that running with ninja -j 1 makes this more deterministic. If so that would confirm.

cristianoc avatar Jul 11 '22 12:07 cristianoc

CC @cknitt

cristianoc avatar Jul 11 '22 12:07 cristianoc

On the linked pr, command 2 seems to be wrong approximately half of the times

cristianoc avatar Jul 11 '22 12:07 cristianoc

I have run node scripts/install -force-lib-rebuild 10 times on https://github.com/rescript-lang/rescript-compiler/pull/5539 with -j 1 and not once has it given a wrong result.

cristianoc avatar Jul 11 '22 12:07 cristianoc

Another observation is that clean / config / build would sometime produce garbled js files with the closing } appearing twice.

cristianoc avatar Jul 11 '22 12:07 cristianoc

Also every single time: doing build a second time runs about 700 steps again. The third time it does nothing.

cristianoc avatar Jul 11 '22 12:07 cristianoc

The problem seems to be that there are two copies of the Js module, and you only modified one of them in #5539.

The duplicate Js module was introduced here: https://github.com/rescript-lang/rescript-compiler/commit/148d57f752c3cfbc30e1dba57c0e2d1dd7c0d23f

cknitt avatar Jul 11 '22 13:07 cknitt

The duplicate Js module was introduced here: 148d57f

Looks like it might have been only introduced to hide certain types used by the compiler and not exposed to the user.

cristianoc avatar Jul 11 '22 16:07 cristianoc

Still, there are race conditions. This file duplication is simply something that makes the race conditions obvious.

cristianoc avatar Jul 11 '22 16:07 cristianoc

CC @TheSpyder

cristianoc avatar Jul 25 '22 05:07 cristianoc

Turns out my problem wasn't race conditions, rather actual compile errors caused by changes on the master branch. Sorry for jumping to conclusions.

TheSpyder avatar Jul 28 '22 10:07 TheSpyder