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

jnr.ffi on ppc64le ubuntu 14.10 and IBM JDK fails PointerTest. #36

Closed
ralphbellofatto opened this issue Mar 20, 2015 · 2 comments
Closed

Comments

@ralphbellofatto
Copy link

Under the IBM JDK we get the following error:

------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running jnr.ffi.PointerTest
RB: PointerTest::pointerArraySetElement
ptr_set_array_element (nil), 0
Unhandled exception
Type=Segmentation error vmState=0x00040000
J9Generic_Signal_Number=00000004 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001

I added instrumentation to isolate the problem:

diff --git a/libtest/PointerTest.c b/libtest/PointerTest.c
index ce642bb..c291c6e 100644
--- a/libtest/PointerTest.c
+++ b/libtest/PointerTest.c
@@ -54,12 +54,15 @@ TEST(pointer);
 void*
 ptr_return_array_element(void **ptrArray, int arrayIndex)
 {
+    printf("ptr_return_array_element %p, %d\n", ptrArray, arrayIndex);  fflush(stdout);
     return ptrArray[arrayIndex];
 }

 void
 ptr_set_array_element(void **ptrArray, int arrayIndex, void *value)
 {
+       printf("ptr_set_array_element %p, %d\n", ptrArray, arrayIndex);  fflush(stdout);
+       printf("ptr_set_array_element *%p, %d\n", *ptrArray, arrayIndex);  fflush(stdout);
     ptrArray[arrayIndex] = value;
 }

diff --git a/src/test/java/jnr/ffi/PointerTest.java b/src/test/java/jnr/ffi/PointerTest.java
index ac6afbf..faa2a18 100644
--- a/src/test/java/jnr/ffi/PointerTest.java
+++ b/src/test/java/jnr/ffi/PointerTest.java
@@ -381,6 +381,7 @@ public class PointerTest {

     @Test
     public void pointerArraySetElement() {
+        System.out.print("RB: PointerTest::pointerArraySetElement\n");
         Pointer[] ary = new Pointer[10];
         Pointer p1 = runtime.getMemoryManager().newPointer(0xdeadbeef & runtime.addressMask());
         Pointer p2 = runtime.getMemoryManager().newPointer(0xfee1dead & runtime.addressMask());
@@ -388,6 +389,7 @@ public class PointerTest {
         assertEquals(p1, ary[0]);
         testlib.ptr_set_array_element(ary, 9, p2);
         assertEquals(p2, ary[9]);
+        System.out.print("RB: PointerTest::pointerArraySetElement-\n");
     }

     @Test public void mixObjectsAndPrimitives() {

The telemetry above shows that we enter the "ptr_set_array_element" function but our pointer is nill.

This is similar to [https://github.com//issues/32,](#32, but not quite the same,

We get through the pointerSetArrayElement test, but fail on the pointerGetArrayElement test for that one.

@lbianc
Copy link
Contributor

lbianc commented Apr 22, 2015

Fix for this issue - #40

@headius
Copy link
Member

headius commented Apr 23, 2015

Fixed by #40.

@headius headius closed this as completed Apr 23, 2015
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

3 participants