bytedeco / javacpp

The missing bridge between Java and native C++
Other
4.46k stars 581 forks source link

Build fails test on Mac OS 12.6.5 (ThreadTest.testJNIThreadAttachFromNativeCallbacks) #680

Open mrlimbic opened 1 year ago

mrlimbic commented 1 year ago

Downloaded latest snapshot and cannot build on intel mac. This test fails. Any ideas why?

[ERROR] Failures: 
[ERROR]   ThreadTest.testJNIThreadAttachFromNativeCallbacks:100
[INFO] 
[ERROR] Tests run: 70, Failures: 1, Errors: 0, Skipped: 0
saudet commented 1 year ago

Which version of the JDK?

mrlimbic commented 1 year ago

I tried jdk 11, 17, 18 and 20.

saudet commented 1 year ago

What's the error message that you get from the failed test?

mrlimbic commented 1 year ago

Assertion error. Looks like took too long.

"Time elapsed: 0.004 s <<< FAILURE!"

org.bytedeco.javacpp.ThreadTest.txt

saudet commented 1 year ago

There's probably a race condition happening on your system for some reason that makes the main thread finish before the other thread. I wouldn't worry about it, but we should figure out how to make the test work more reliability. A Thread.sleep(100) before that line might do the trick.

mrlimbic commented 1 year ago

I added Thread.sleep(100) before the assert and still fails.

Going to try on my new laptop which is running a later Mac OS to see if same happens.

-------------------------------------------------------------------------------
Test set: org.bytedeco.javacpp.ThreadTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.43 s <<< FAILURE! - in org.bytedeco.javacpp.ThreadTest
testJNIThreadAttachFromNativeCallbacks(org.bytedeco.javacpp.ThreadTest)  Time elapsed: 0.11 s  <<< FAILURE!
java.lang.AssertionError
    at org.bytedeco.javacpp.ThreadTest.testJNIThreadAttachFromNativeCallbacks(ThreadTest.java:107)
mrlimbic commented 1 year ago

Tried building on my intel laptop with JDK 17 + Mac OS 10.13.1(a) but same test fails again.

Do you really think it is not indicative of a problem on Mac OS, only the test that is not good?

saudet commented 1 year ago

@masterav10 Any ideas?

masterav10 commented 1 year ago

Have you tried pulling out the relevant parts from the generated "jnijavacpp.cpp" and see how they behave natively? I use visual studio on Windows, which is where I do most of my testing. I remember doing this quite a bit when I was testing the original feature.

Without looking too closely, I didn't touch anything mac-related, unless you are running a cpp11 compiler. In this case, you get the new behavior.