JuliaPy / PythonCall.jl

Python and Julia in harmony.
https://juliapy.github.io/PythonCall.jl/stable/
MIT License
776 stars 63 forks source link

Malloc error when using juliacall include #352

Closed EmanuelCastanho closed 1 year ago

EmanuelCastanho commented 1 year ago

I have a Julia file with the following test code, lets call it classification.jl. This file is inside a folder called modules and has the following code:

# install packages
import Pkg; Pkg.add("Flux")
import Pkg; Pkg.add("BSON")
import Pkg; Pkg.add("Glob")

# import packages
using Flux
using BSON
using Glob
using Base.Threads

function test(a, b)
    return a+b
end

I want to include this file inside a Python module with functions, the name of the file is classification.py and it is also inside modules. It has the following code inside:

from juliacall import Main as julia

def test_function(inputs):
    julia.include("modules/classification.jl")
    s = julia.test(3, 4)
    print(s)

Finally, the Python module will be called by a main Python script.

from modules.classification import *

This is giving me the following error:

python(11210,0x7ff85c3a64c0) malloc: *** error for object 0xffffffff00000000: pointer being freed was not allocated
python(11210,0x7ff85c3a64c0) malloc: *** set a breakpoint in malloc_error_break to debug

But when I ignore the packages it can run... Do you know how I can debug this? My colleague is using Windows and he doesn't have this problem. I am using mcOS.

EmanuelCastanho commented 1 year ago

So, I put using Flux in comment and it works, the problem is that I need Flux...

EmanuelCastanho commented 1 year ago

This is solved: Now I make the import of the Julia packages in the main Python script and not inside the classification.jl module.