Opened 11 years ago

Closed 7 years ago

#251 closed defect (fixed)

CFFI callbacks don't unbox integer values

Reported by: stassats Owned by: Mark Evenson
Priority: blocker Milestone: 1.4.0
Component: libraries Version: 1.1.0-dev
Keywords: quicklisp cffi cl+ssl Cc: stassats@…
Parent Tickets:

Description

It very well may be a cffi issue.

Compile the following C code
with gcc -shared test.c -o test.so

#ifdef WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif

DLLEXPORT
short test(short (*f)(short, short))
{
 return f(23, 24);
}

Then

(cffi:load-foreign-library "/tmp/test.so")

(cffi:defcfun test :short
  (function :pointer))

(cffi:defcallback (test-callback)
    :short ((a :short) (b :short))
  (+ a b))

And finally

(test (cffi:get-callback 'test-callback)) =>
The value #<java.lang.Short 23 {5EE76547}> is not of type NUMBER.

That's on 64-bit x86 linux, with OpenJDK 1.6.0_24 and jna downloaded by maven.

Change History (19)

comment:1 Changed 11 years ago by stassats

Cc: stassats@… added

comment:2 Changed 11 years ago by Mark Evenson

Component: javalibraries
Keywords: quicklisp cffi jna added
Owner: changed from nobody to Mark Evenson

comment:3 Changed 11 years ago by Mark Evenson

Priority: majorcritical
Status: newaccepted

comment:4 Changed 11 years ago by Mark Evenson

Keywords: hunchentoot added
Priority: criticalmajor

Need some basic macrology--and a reasonable abstraction of type-- in [ABCL's cffi-sys:convert-args-to-lisp-values][cffi-abcl]

[cffi-abcl]: https://github.com/easye/cffi/commit/c630aaf3b41501d3d2ac60b94461f96627fce627

No longer critical, as CL+SSL at least sort of loads. Callbacks still fail (sometimes) until the types are properly reasoned about.

comment:5 Changed 11 years ago by Mark Evenson

Milestone: 1.1.01.1.1
Summary: ffi callbacks don't unbox integer valuesCFFI callbacks don't unbox integer values

Problem is with upstream cffi abcl implementation, so does not block abcl-1.1.

comment:6 Changed 11 years ago by Mark Evenson

Milestone: 1.1.11.1.0
Resolution: worksforme
Status: acceptedclosed

comment:7 Changed 11 years ago by Mark Evenson

Milestone: 1.1.01.2.0

comment:8 Changed 11 years ago by Mark Evenson

Resolution: worksforme
Status: closedreopened

comment:9 Changed 11 years ago by Mark Evenson

pointerp and null-pointer-p don't work on non-pointers

comment:10 Changed 11 years ago by stassats

pointerp and null-pointer-p are not related.
The problem now with the return value from the callback.

JNA: Callback $Proxy2@7dc6a657 threw the following exception:
java.lang.ClassCastException?: java.lang.Integer cannot be cast to java.lang.Short

comment:11 Changed 11 years ago by Evenson Not Org

Keywords: hunchentoot removed

No longer blocks hunchentoot, but CFFI stills fails when actually trying to use CL+SSL.

comment:12 Changed 11 years ago by Evenson Not Org

Keywords: cl+ssl added; jna removed

comment:13 Changed 11 years ago by Evenson Not Org

Priority: majorblocker

comment:14 Changed 11 years ago by Evenson Not Org

Milestone: 1.2.01.3.0

comment:15 Changed 10 years ago by Mark Evenson

Milestone: 1.3.02.0

Ticket retargeted after milestone closed

comment:16 Changed 10 years ago by Mark Evenson

Milestone: 2.02.0.0

Milestone renamed

comment:17 Changed 10 years ago by Mark Evenson

Milestone: 2.0.01.4.0

comment:18 Changed 7 years ago by Mark Evenson

Milestone: 1.4.01.5.0

Ticket retargeted after milestone closed

comment:19 Changed 7 years ago by Mark Evenson

Milestone: 1.5.01.4.0
Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.