- 
    Bug 
- 
    Resolution: Fixed
- 
     P3 P3
- 
    None
- 
    repo-panama
                    The library I use declares a function pointer within a struct's field 
named "read" [1]. I think you see where this is going...
typedef struct ucs_config_parser {
int (*read) (const char *buf, void *dest,
const void *arg);
int (*write)(char *buf, size_t max,
const void *src, const void
*arg);
ucs_status_t (*clone)(const void *src, void *dest,
const void *arg);
void (*release)(void *ptr, const void *arg);
void (*help)(char *buf, size_t max, const
void *arg);
const void *arg;
} ucs_config_parser_t;
Since "unistd.h" also declares a "read" function [2], jextract then
(correctly) generates a MethodHandle for it
but uses the wrong FunctionDescriptor belonging to ucx's "read" in the
process.
static final FunctionDescriptor read$FUNC_ =
FunctionDescriptor.of(C_INT,
C_POINTER,
C_POINTER,
C_POINTER
);
static final MethodHandle read$MH_ = RuntimeHelper.downcallHandle(
LIBRARIES, "read",
"(ILjdk/incubator/foreign/MemoryAddress;J)J",
read$FUNC_, false
);
As you can see the generated FunctionDescriptor and the descriptor
string ("(ILjdk/incubator/foreign/MemoryAddress;J)J")
do not match. On startup, I immediately get the following Exception
originating from the downcallHandle call.
Caused by: java.lang.IllegalArgumentException: Carrier size
mismatch: int != b64[abi/kind=POINTER]
            
named "read" [1]. I think you see where this is going...
typedef struct ucs_config_parser {
int (*read) (const char *buf, void *dest,
const void *arg);
int (*write)(char *buf, size_t max,
const void *src, const void
*arg);
ucs_status_t (*clone)(const void *src, void *dest,
const void *arg);
void (*release)(void *ptr, const void *arg);
void (*help)(char *buf, size_t max, const
void *arg);
const void *arg;
} ucs_config_parser_t;
Since "unistd.h" also declares a "read" function [2], jextract then
(correctly) generates a MethodHandle for it
but uses the wrong FunctionDescriptor belonging to ucx's "read" in the
process.
static final FunctionDescriptor read$FUNC_ =
FunctionDescriptor.of(C_INT,
C_POINTER,
C_POINTER,
C_POINTER
);
static final MethodHandle read$MH_ = RuntimeHelper.downcallHandle(
LIBRARIES, "read",
"(ILjdk/incubator/foreign/MemoryAddress;J)J",
read$FUNC_, false
);
As you can see the generated FunctionDescriptor and the descriptor
string ("(ILjdk/incubator/foreign/MemoryAddress;J)J")
do not match. On startup, I immediately get the following Exception
originating from the downcallHandle call.
Caused by: java.lang.IllegalArgumentException: Carrier size
mismatch: int != b64[abi/kind=POINTER]
- relates to
- 
                    JDK-8262019 jextract crashes with clang overridable function extension -           
- Closed
 
-         
 
        