-
Notifications
You must be signed in to change notification settings - Fork 33
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
Sizeof broken after android-related merges #5
Comments
If one of the fields of the Sizeof class was used before the CL class was loaded, this lead to an UnsatisfiedLinkError, as reported in issue #5
Thanks for this hint. This was a bit subtle: It only happened when the This should now be fixed, and covered with a new (fairly trivial...) test case. For me, the test threw the same error before, and now it passes, so hopefully, it resolved the issue for you as well. |
Unfortunately, after cleaning everything and rebuilding, the error is still there (yes, I deleted JOCL and JOCL.build and did everything from the scratch): Caused by: java.lang.UnsatisfiedLinkError: org.jocl.Sizeof.computePointerSizeNative()I |
To clarify: your new test in JOCL passes, but the tests in my library that uses JOCL still have the Sizeof load problem. |
OK, that's odd - and it's distressing that I can't reproduce this right now. Is there any test case that might expose the same behavior (on windows?). I wonder whether this is related to some classloader magic in Clojure, but this would not explain why loading the library works for the main CL class, but not for the In fact, without the possibility to analyze this further, I don't see what I could to right now, except for undoing the change. If until tomorrow evening nobody (also @phlip9, referring to the discussion in #4 (comment) ) has another idea, I'd rather go back to use the |
Thanks for looking at this. Unfortenately, I can't provide a java test case, since I am using it from Clojure library that has many methods, so I can't identify why Sizeof fails. What I discovered is not much: CL calls work, Sizeof importing (interactive, from repl) works, but if i try to use Sizeof directly, even AFTER CL has been loaded and called, I get that exception. |
@gpu I actually just ran into this issue while testing on an Android device. Without calling something in CL first, the native library doesn't load and |
It doesn't help (at least in my case) but maybe a solution would be to move the calculatePointerSizeNative to the CL class? May be the problem is that loadNativeLibrary is called twice? |
It seems to work with the latest changes... I added a few print statements to see the control flow:
As I suspected, calling This is also running through Scala on Android, which may or may not affect the result. If we move |
I tried various changes with how CL and Sizeof are called, as well as tried changing CL and Sizeof classes themselves and the problem is still there. It seems to me, as gpu suggested, that the problem is in exotic class loading. @gpu @phlip9 This works for me: private static int computePointerSize()
{
if (LibUtils.calculateOS() == LibUtils.OSType.ANDROID) {
return computePointerSizeNative();
} else {
String bits = System.getProperty("sun.arch.data.model");
if (bits.equals("32"))
{
return 4;
}
else if (bits.equals("64"))
{
return 8;
}
else
{
System.err.println(
"Unknown value for sun.arch.data.model - assuming 32 bits");
return 4;
}
}
} |
Yes, I also considered making the native method a package-private method in the On the one hand, it seemed clear (in hindsight) : When using But it's entirely unclear to me why it does not work in the Clojure setup. Introducing some of the
which means that during class loading, it seems to do the initialization of the So @phlip9 if the solution proposed by Dragan works on Android as well, then this may be a feasible workaround, and I'd add it later today to at least have a working state for both worlds. But I'd really like to know what went wrong there under the hood. @blueberry It would be great if you could add some basic |
I've already tried that, but did not find any hint: Compiling uncomplicate.clojurecl.info
======= loadNativeLibrary ENTER
======= loadNativeLibrary !nativeLibraryLoaded ENTER
======= loadNativeLibrary !nativeLibraryLoaded LEAVE
======= loadNativeLibrary LEAVE
======= loadNativeLibrary ENTER
======= loadNativeLibrary LEAVE
======= computerPointerSize ENTER
java.lang.UnsatisfiedLinkError: org.jocl.Sizeof.computePointerSizeNative()I, compiling:(uncomplicate/clojurecl/info.clj:296:3)
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.jocl.Sizeof.computePointerSizeNative()I, compiling:(uncomplicate/clojurecl/info.clj:296:3) |
The computation of the pointer size in a generic way has several caveats, as seen in issue #5 This is an attempt to support Android-based systems as well as desktop systems.
OK, this trace looks like it indeed does load the library (without errors). I could only guess now that this may be related to the use of different I have added the solution that Dragan suggested, and which hopefully works in both setups. However, I'm still feeling uncomfortable about this, and will definitely leave this issue open until it is clear what's going on there.... |
Thank you for the quick response. Please, when you are ready to release a RC to the maven central, ping me to do the linux 64-bit build (and also 32 bit if it could be done on the same system from the cmake you supply). |
Thanks. As there seems to be no response from the original reporter: Did you encounter any issues during linking, related to the |
No, JOCL works well with a fairly non-trivial Clojure code. |
I have just built and installed JOCL on Arch Linux and discovered regressions with the newest android-related changes in Sizeof, when used in linux.
JOCL builds and tests fine, but when I tried it with a well testet ClojureCL, the built failed, with a messages related to the newly introduced Sizeof native method:
java.lang.UnsatisfiedLinkError: org.jocl.Sizeof.computePointerSizeNative()I
This happens with the latest commit 18d9a04
I did a checkout of last week's commit 862f2ab: JOCL gets built, AND the existing projects work.
The text was updated successfully, but these errors were encountered: