mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Files

I've had a lot of Puzzles nightly builds fail recently in the NestedVM stage, with a 'jar' command producing a message along these lines: java.util.zip.ZipException: attempt to write past end of STORED entry at java.base/java.util.zip.ZipOutputStream.write(ZipOutputStream.java:337) at jdk.jartool/sun.tools.jar.Main.copy(Main.java:1250) at jdk.jartool/sun.tools.jar.Main.copy(Main.java:1263) at jdk.jartool/sun.tools.jar.Main.addFile(Main.java:1211) at jdk.jartool/sun.tools.jar.Main.create(Main.java:879) at jdk.jartool/sun.tools.jar.Main.run(Main.java:319) at jdk.jartool/sun.tools.jar.Main.main(Main.java:1681) Suppressed: java.util.zip.ZipException: invalid entry size (expected 0 but got 786 bytes) at java.base/java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:288) at java.base/java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:361) at java.base/java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:238) at java.base/java.util.zip.ZipOutputStream.close(ZipOutputStream.java:378) at jdk.jartool/sun.tools.jar.Main.create(Main.java:854) ... 2 more It's hard to work out exactly what this error dump means, and web-searching for the error message isn't much help because the same exception can occur in application code using java.util.zip, and most mentions on the web are about that, and not about what I want to know, which is why it might happen in the 'jar' program in particular. However, the clues visible in that message suggest that 'jar' had somehow got confused about the size of one of the files it was adding to the jar archive, in that it initially decided it was 0 bytes long and later found it was longer. That suggests a problem of excessive parallelism between the build steps, perhaps due to a missing dependency in the makefile, which might plausibly cause the 'jar' step to be running already while some file it needs to read is still being written. (Which would also explain why it doesn't happen every time.) An eyeball review of cmake/platforms/nestedvm.cmake didn't find any obvious missing dependencies. But I vaguely remembered that in some other context I'd had trouble with cmake 'add_custom_command'. So in this commit I replace all those custom commands with custom _targets_, listing the previous OUTPUT files as BYPRODUCTS. And then the dependencies are written using the target names, instead of the file names. I don't fully understand why this should make a difference. But it seems more reliable in a soak test, and still builds the right things, so I'll commit it and see if it makes the flakiness in the actual nightly builds stop happening.