-
Notifications
You must be signed in to change notification settings - Fork 588
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
Can't deallocate memory returned by fftw_export_wisdom_to_string() #429
Comments
That would be |
Ah, no, |
So if I'm reading it right, the issue comes from using the pre-built FFTW dlls, when the native parts of javacpp are compiled with a different compiler or different compiler version? |
No, it's because FFTW doesn't support MSVC, only GCC. It looks like it's possible to hack it to build with MSVC, but whatever, it's most likely happier with GCC anyway. I'll include a |
But yes, JavaCPP itself uses MSVC on Windows because that's the standard compiler on that platform. |
OK, thanks! It's not a blocker for me because I'm only using it right before exit, so I can afford to leak some memory. Incidentally, I wouldn't have uncovered this except fftw_export_wisdom_to_filename() wasn't working for me at all - it was always returning failure. http://www.fftw.org/install/windows.html#DLLwisdom seems to think this issue shouldn't affect that, but maybe it is? It's not like it returns a detailed errno to figure out what's going on... |
|
…isdom_to_string()` (issue bytedeco/javacpp#429)
Just: int res = fftwf_export_wisdom_to_filename(WISDOM_FILE.toString());
System.out.printf("Wisdom %s to %s\n", res == 1 ? "successfully written" : "writing failed", WISDOM_FILE); And it always fails, which I can verify by no file being created. I switched to exporting the string and writing it with Java (with the exact same path constant), which works (but leaks memory). Importing using fftwf_import_wisdom_from_filename(WISDOM_FILE.toString()) works fine. (For reasons, I switch to fftwf routines, which I know aren't compatible with fftw routines, but I switched globally - the problem was the same with fftw.) Edit: Or, it used to always fail. It's working now. I think the issue is that it was unable to create the file - maybe a permissions issue of some type? But it seem to be fine with overwriting the file once it exists. |
Ah, ok, yes probably a permission issue. Thanks for reporting! |
This addition has been released with version 1.5.5! Enjoy |
Here's a minimal repro. I'm seeing this with javacpp and javacpp-presets 1.5.4, with only the 8 jars javacpp{-platform,-windows-x86,-windows-x86_64,,}.jar and fftw{-platform,-windows-x86,-windows-x86_64,,}.jar on the classpath.
This produces:
As you can see, the two pointers have very different address ranges, which shows that they're being allocated from different heaps. (Which explains why free()'ing crashes.) fftw_export_wisdom_to_string() is documented as returning memory that needs to be free'd, see here: http://www.fftw.org/fftw3_doc/Wisdom-Export.html. And you can clearly see in the code that they're using plain malloc() for the result: https://github.com/FFTW/fftw3/blob/master/api/export-wisdom-to-string.c
So, how do I get access (from Java) to the free() that corresponds to the malloc() that fftw is linking against?
The text was updated successfully, but these errors were encountered: