Skip to content

Segfault when using cargo test with glfw #3927

Closed
@gmorenz

Description

@gmorenz

Code:

extern crate glfw;
#[test]
fn test() {
    unsafe{glfw::ffi::glfwInit() };
    unsafe{glfw::ffi::glfwTerminate()};
}

Output of cargo test

   Compiling raytracer v0.1.0 (file:///home/normal/raytracer)
    Finished dev [unoptimized + debuginfo] target(s) in 0.44 secs
     Running target/debug/deps/raytracer-9ee32f3ce5c79175

running 1 test
test test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

error: process didn't exit successfully: `/home/normal/raytracer/target/debug/deps/raytracer-9ee32f3ce5c79175` (signal: 11, SIGSEGV: invalid memory reference)

To learn more, run the command again with --verbose.

Backtrace (via gdb on coredump, for some reason it works when running directly in gdb)

#0  0x00007f949a3f2150 in ?? ()
#1  0x00007f94a070b429 in __nptl_deallocate_tsd.part.4 () from /usr/lib/libpthread.so.0
#2  0x00007f94a070c498 in start_thread () from /usr/lib/libpthread.so.0
#3  0x00007f94a023654f in clone () from /usr/lib/libc.so.6

Glfw-rs issue that I probably didn't need to open here.

Tested on stable and nightly. Code works properly when run as a main function in a binary instead of as a test.

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