-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
ZoneRules.lastRuleCache side effects during source cache build fail native image generation #2637
Comments
This was originally reported in quarkusio/quarkus#10309. |
I'm testing out to see if recompute field value would work here, but I don't think it will. Even if you replace the value in the heap before computing the heap contents, you'd get rid of the mutations caused by the class file navigation, but the source cache would still mutate it and lead to the same error. You'd need a second recompute call before writing the heap (or some reflection magic). |
Actually, recomputing the cache to be a new instance seems to work. |
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
* Before this patch, the image would contain zone rules cache from the JVM computing the image. * Side effects here, such as class or source cache lookups, were affecting its contents and leading to error when writing image. * With this change, we guarantee that the zone rules cache in the image is a brand new instance, separate from the one in the JVM computing the image.
This is a bug in native image debug symbol generation. In particular, it's an issue with the way source cache generation is handled.
When
ImageClassLoader
walks the jars to find the classes, it inadvertently fills up theZoneRules.lastRulesCache
with time zone offset transitions for the years for which the classes were last modified. Typically, this would be filled up with years 2020 and 2019. See a typical stacktrace of this.After the heap is creating, debug symbols generates the source cache, and at that port it can lookup classes in
*-sources.jar
files. This lookup can end up touching the sameZoneRules.lastRuleCache
(see stacktrace), and if by chance, it adds a year that was not present after looking up classes, e.g. 2014, it will pollute the heap after snapshotting the heap. Native image detects this and fails with an error like:I've built a reproducer for this issue here.
Some observations:
Files.isRegularFile()
cannot be substituted byFile.isDirectory
because the Path is a Path within a Zip FileSystem (e.g. a jar), and method is unsupported for that type of FS.zipfs.ZipUtils
but obviously those don't have an effect during the heap build time.I'm unsure yet about a fix here:
ZoneId.systemDefault()
.lastRulesCache
after navigating the classes, and clear it again after navigating the source cache (before writing the heap).The text was updated successfully, but these errors were encountered: