Skip to content

Is convert_args safe with finalizer? #95

Description

@clouds56

Now JavaCall tries to use saved_args to keep reference of JavaObject while pass arg.ptr into JNI FFI.

JavaCall.jl/src/core.jl

Lines 244 to 248 in d6c3678

savedArgs, convertedArgs = convert_args(argtypes, args...)
result = ccall(callmethod, Ptr{Nothing}, (Ptr{JNIEnv}, Ptr{Nothing}, Ptr{Nothing}, Ptr{Nothing}),
penv, obj.ptr, jmethodId, convertedArgs)
result==C_NULL && geterror()
return convert_result(rettype, result)

But saved_args is not referenced after it created, it might be garbage collected at any time (even before ccall).
I learnt from this gc would only occurs when allocates memory (so current code might work now), but it is hard to trace memory allocation.

Is there any better solution that telling gc not to collect saved_args?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions