Skip to content

Do we need to pyincref here? #261

@colinfang

Description

@colinfang

I am investigating a Segmentation Fault possibly because of py_decref issue.

--> Start pydecref: ps=PyObject NULL"
"Start pydecref 140082311589056: js=jL_Function_call|kw_"

signal (11): Segmentation fault

The line kw = PyDict{Symbol,PyAny}(PyObject(kw_)) looks suspecious.
We borrowed a PyPtr, don't we need to pyincref it?

It also aplies to line args = PyObject(args_)

function jl_Function_call(self_::PyPtr, args_::PyPtr, kw_::PyPtr)
    ret_ = convert(PyPtr, C_NULL)
    args = PyObject(args_)
    try
        f = unsafe_pyjlwrap_to_objref(self_)::Function
        if kw_ == C_NULL
            ret = PyObject(f(convert(PyAny, args)...))
        else
            kw = PyDict{Symbol,PyAny}(PyObject(kw_))
            kwargs = [ (k,v) for (k,v) in kw ]
            ret = PyObject(f(convert(PyAny, args)...; kwargs...))
        end
        ret_ = ret.o
        ret.o = convert(PyPtr, C_NULL) # don't decref
    catch e
        pyraise(e)
    finally
        args.o = convert(PyPtr, C_NULL) # don't decref
    end
    return ret_::PyPtr
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions