Opened 14 years ago

Closed 10 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 by stassats, 14 years ago

Cc: stassats@… added

comment:2 by Mark Evenson, 14 years ago

Component: java → libraries
Keywords: quicklisp cffi jna added
Owner: changed from nobody to Mark Evenson

comment:3 by Mark Evenson, 14 years ago

Priority: major → critical
Status: new → accepted

comment:4 by Mark Evenson, 14 years ago

Keywords: hunchentoot added
Priority: critical → major

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 by Mark Evenson, 14 years ago

Milestone: 1.1.0 → 1.1.1
Summary: ffi callbacks don't unbox integer values → CFFI callbacks don't unbox integer values

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

comment:6 by Mark Evenson, 14 years ago

Milestone: 1.1.1 → 1.1.0
Resolution: → worksforme
Status: accepted → closed

comment:7 by Mark Evenson, 14 years ago

Milestone: 1.1.0 → 1.2.0

comment:8 by Mark Evenson, 14 years ago

Resolution: worksforme
Status: closed → reopened

comment:9 by Mark Evenson, 14 years ago

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

comment:10 by stassats, 14 years ago

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 by Evenson Not Org, 13 years ago

Keywords: hunchentoot removed

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

comment:12 by Evenson Not Org, 13 years ago

Keywords: cl+ssl added; jna removed

comment:13 by Evenson Not Org, 13 years ago

Priority: major → blocker

comment:14 by Evenson Not Org, 13 years ago

Milestone: 1.2.0 → 1.3.0

comment:15 by Mark Evenson, 13 years ago

Milestone: 1.3.0 → 2.0

Ticket retargeted after milestone closed

comment:16 by Mark Evenson, 13 years ago

Milestone: 2.0 → 2.0.0

Milestone renamed

comment:17 by Mark Evenson, 13 years ago

Milestone: 2.0.0 → 1.4.0

comment:18 by Mark Evenson, 10 years ago

Milestone: 1.4.0 → 1.5.0

Ticket retargeted after milestone closed

comment:19 by Mark Evenson, 10 years ago

Milestone: 1.5.0 → 1.4.0
Resolution: → fixed
Status: reopened → closed
Note: See TracTickets for help on using tickets.