Skip to content
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

Cannot unpack libzstd-jni-1.5.4-2 ?!?! When using virtual threads on Correto-21 + Windows #295

Open
javafanboy opened this issue Dec 21, 2023 · 11 comments

Comments

@javafanboy
Copy link

javafanboy commented Dec 21, 2023

When the first thing I do with the zstd library (using JDK 21 running on Windows 10) is to create a dictionary I get the following exception:

java.lang.ExceptionInInitializerError:: Cannot unpack libzstd-jni-1.5.4-2: C:\Users\myaccount\AppData\Local\Temp\libzstd-jni-1.5.4-217418534051402262760.dll (The process cannot access the file because it is being used by another process)

any thought on why I get it and/or what I can try to avoid it?

@javafanboy
Copy link
Author

Also using compressBound seem to trigger this for me now.

@javafanboy
Copy link
Author

May be related to timing / parallel threads - when I change the number of threads used in my tests I can make the problem come and go but not in an intuitive way....

@luben
Copy link
Owner

luben commented Dec 22, 2023

Hmm, interesting - all the loading/isLoaded/etc methods are synchronized so there is no way 2 or them to run concurrently. On another side, the loaded flag https://github.com/luben/zstd-jni/blob/master/src/main/java/com/github/luben/zstd/util/Native.java#L50 is not atomic, so may be the next thread does not observe the changed value. Let me make it atomic.

@luben
Copy link
Owner

luben commented Dec 22, 2023

Looking at the error - it tries to unpack the native DLL file onto file that exists and is already used. The question is why File.createTempFile is returning the same filename?

luben added a commit that referenced this issue Dec 22, 2023
@javafanboy
Copy link
Author

javafanboy commented Dec 22, 2023 via email

@javafanboy
Copy link
Author

javafanboy commented Dec 22, 2023 via email

@luben
Copy link
Owner

luben commented Dec 22, 2023

Hmm, that's interesting - virtual threads could be the issue here as I have not tested with them.

@javafanboy
Copy link
Author

javafanboy commented Dec 22, 2023 via email

@javafanboy
Copy link
Author

javafanboy commented Dec 22, 2023 via email

@javafanboy
Copy link
Author

javafanboy commented Dec 23, 2023 via email

@luben
Copy link
Owner

luben commented Dec 29, 2023

Hmm, strange bug in Correto/Windows then. I test with Correto but on Linux... I will leave open this issue and improve the title so if other people experience the same can benefit of your investigation.

@luben luben changed the title Cannot unpack libzstd-jni-1.5.4-2 ?!?! Cannot unpack libzstd-jni-1.5.4-2 ?!?! When using virtual threads on Correto-21 + Windows Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants