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

missing throw statements on ffi callback #4661

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
@kares
Member

kares commented Jun 9, 2017

not sure about this one spec:ffi fails when the error is actually thrown

someone more familiar with the piece should look at it ...

HEREs the failed job: https://travis-ci.org/kares/jruby/jobs/241153466

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Jun 9, 2017

Member

Reproduced locally. I suspect there's some logic for unwrapping the Mapped type that did not get into our FFI.

Member

headius commented Jun 9, 2017

Reproduced locally. I suspect there's some logic for unwrapping the Mapped type that did not get into our FFI.

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius Jun 9, 2017

Member

This fixes it for me. Similar code seems to be in other type-wrangling logic.

diff --git a/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java b/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
index 34d68a3cf4..79799dd89d 100644
--- a/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
+++ b/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
@@ -110,6 +110,10 @@ public class CallbackInfo extends Type {
                     + returnType.getMetaClass().getName() + " (expected FFI::Type)");
         }
 
+        if (returnType instanceof MappedType) {
+            returnType = ((MappedType) returnType).getRealType();
+        }
+
         if (!(paramTypes instanceof RubyArray)) {
             throw context.runtime.newTypeError("wrong argument type "
                     + paramTypes.getMetaClass().getName() + " (expected Array)");
Member

headius commented Jun 9, 2017

This fixes it for me. Similar code seems to be in other type-wrangling logic.

diff --git a/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java b/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
index 34d68a3cf4..79799dd89d 100644
--- a/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
+++ b/core/src/main/java/org/jruby/ext/ffi/CallbackInfo.java
@@ -110,6 +110,10 @@ public class CallbackInfo extends Type {
                     + returnType.getMetaClass().getName() + " (expected FFI::Type)");
         }
 
+        if (returnType instanceof MappedType) {
+            returnType = ((MappedType) returnType).getRealType();
+        }
+
         if (!(paramTypes instanceof RubyArray)) {
             throw context.runtime.newTypeError("wrong argument type "
                     + paramTypes.getMetaClass().getName() + " (expected Array)");

@kares kares removed the feedback needed label Jun 9, 2017

@kares kares changed the title from adding a missing throw statements on ffi callback fails spec to missing throw statements on ffi callback Jun 10, 2017

@kares kares added this to the JRuby 9.1.11.0 milestone Jun 10, 2017

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Jun 10, 2017

Member

now on master (6d924dc), thanks

Member

kares commented Jun 10, 2017

now on master (6d924dc), thanks

@kares kares closed this Jun 10, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment