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

Cargo test makes gtk application crash on OSX #5438

Closed
GuillaumeGomez opened this issue Apr 28, 2018 · 10 comments
Closed

Cargo test makes gtk application crash on OSX #5438

GuillaumeGomez opened this issue Apr 28, 2018 · 10 comments

Comments

@GuillaumeGomez
Copy link
Member

Sorry but I can't get much information out of the run:

cargo test
   Compiling gtk-test v0.1.0 (file:///Users/imperio/rust/gtk-test)
    Finished dev [unoptimized + debuginfo] target(s) in 2.33 secs
     Running target/debug/deps/gtk_test-663922f61f003d55

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/basic-4ecdfe72bcff51e8

running 1 test

(process:1424): Gtk-WARNING **: 01:56:43.472: Locale not supported by C library.
	Using the fallback 'C' locale.
error: process didn't exit successfully: `/Users/imperio/rust/gtk-test/target/debug/deps/basic-4ecdfe72bcff51e8` (signal: 11, SIGSEGV: invalid memory reference)

It runs perfectly fine when the test code is moved inside a main and then run with cargo run but it just crashes without reason otherwise...

@antoyo
Copy link

antoyo commented Apr 28, 2018

I guess this is this test.

@ehuss
Copy link
Contributor

ehuss commented Apr 29, 2018

I'd suspect the issue is this:

The thread where init was called is considered the main thread. OS X has its own notion of the main thread and init must be called on that thread.

AFAIK, you cannot limit libtest to the main thread.

Setting harness=false in Cargo.toml, and rewriting your test to be fn main makes it pass for me.

@GuillaumeGomez
Copy link
Member Author

That is what we thought then. Can't we set this behavior as default on OSX in cargo?

@matklad
Copy link
Member

matklad commented Apr 29, 2018

A random idea, but wouldn’t passing test-threads=1 help? By default, tests are multithreaded, so defaulting to main thread on macos does not make sense.

@GuillaumeGomez
Copy link
Member Author

@matklad: Still failing.

@ehuss
Copy link
Contributor

ehuss commented Apr 29, 2018

wouldn’t passing test-threads=1 help

It still spins up 1 thread off main to run the tests on. Not sure if that's fixable (see a very old discussion here).

@GuillaumeGomez
Copy link
Member Author

Well, it does help in a way since it allows to avoid GTK context conflicts. But that doesn't solve the issue on OSX. I'll just add explanations about this in the README and hope that people will add harness = false.

@dwijnand
Copy link
Member

Is it possible to move forward with this ticket in cargo, or should we just close it?

@matklad
Copy link
Member

matklad commented Jan 13, 2019

@dwijnand closing makes sense to me: it's not a Cargo issue, its a test harness issue.

@ehuss
Copy link
Contributor

ehuss commented Jan 13, 2019

There was a recent change (rust-lang/rust#56243) so that libtest will not spawn a thread when concurrency is set to 1. That may be good enough.

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

5 participants