Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CxxWrap 0.15.0 shared library loader is broken #421

Closed
djturizo opened this issue Mar 28, 2024 · 2 comments
Closed

CxxWrap 0.15.0 shared library loader is broken #421

djturizo opened this issue Mar 28, 2024 · 2 comments

Comments

@djturizo
Copy link

djturizo commented Mar 28, 2024

The shared library I'm using cannot be loaded under CxxWrap 0.15.0. Consider the file test.jl

module Lib
    using CxxWrap
    @wrapmodule(() -> joinpath(@__DIR__, "lib.so"))
    function __init__()
        @initcxx
        return
    end
end
println("OK")

Then on CxxWrap 0.15.0:

$ julia test.jl
malloc(): invalid size (unsorted)
$ julia test.jl
malloc(): smallbin double linked list corrupted
$ julia test.jl

[19701] signal (6.-6): Aborted
in expression starting at /home/daniel/EzPC-OPF/SCI/julia/test.jl:3
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
raise at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
corrupted size vs. prev_size
Aborted

The same code gives me non-deterministic fatal errors. CxxWrap 0.14.2 works perfectly fine though:

$ julia test.jl
OK
@barche
Copy link
Collaborator

barche commented Apr 1, 2024

Hi, did you build the library against libcxxwrap-julia 0.12.2? To ensure complete compatibility, you also need to build Julia itself from source and build libcxxwrap-julia against that, and then build your own lib against that, all with the same compiler.

@djturizo
Copy link
Author

djturizo commented Apr 4, 2024

I was compiling against libcxxwrap-julia 0.11.2 because libcxxwrap-julia 0.12.2 would give me an error. I found the reason though. To explain, consider a simple class with an external function:

struct MyClass {
    int count;
    MyClass(int count_){
        this->count = count_;
    }
};

void add_one(MyClass* obj) {
    obj->count++;
    return;
}

In libcxxwrap-julia 0.11.2 it is valid to do:

JLCXX_MODULE define_julia_module(jlcxx::Module& mod) {
    mod.add_type<MyClass>("MyClass")
        .constructor<int>()
        .method("add_one", &add_one)
    ;
}

In libcxxwrap-julia 0.12.2 however the previous code gives an error. I guess it's my fault for adding functions external to a class as methods.

@djturizo djturizo closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants