-
Notifications
You must be signed in to change notification settings - Fork 38
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 locking up #107
Comments
To first exclaim an obvious "no warranty" remark, the front of the wrapper's README curently states:
If you have already tried If it becomes valuable to use in a thread-safe way, we would need to put in more work to make that safe and reasonable... |
In my mind I had thought cargo was running each test as a separate process - obviously not the case given the naming of the environment variables to change the behavior. There is another work around, for each thread if you call the xmlInitParser() method it works too: #[test]
fn test_a() {
unsafe {
libxml::bindings::xmlInitParser();
}
do_xml_things(
SCHEMA,
"<note><to>Anyone</to><from>Me</from><heading /><body /></note>",
);
} In my use case I will consider using this call in the module the XML is being processed in as it will avoid having to make changes to the CI system. |
I recently encountered the deadlock and confirmed the resolution by @o087D works for me as well. I suspect we can use a small PR that adds to parser.rs: use std::sync::Once;
static INIT_LIBXML_PARSER: Once = Once::new();
// then in Parser::default() and Parser::default_html()
INIT_LIBXML_PARSER.call_once(|| unsafe {
libxml::bindings::xmlInitParser();
}); which could successfully guard every |
I have come across an issue with cargo locking up, I expect due to some race condition? The following code exhibits the behavior on my local development machine and on our CI servers:
Running
cargo test
sometimes (1 in 3 times for me) results in all the tests locking up. RunningRUST_TEST_THREADS=1 cargo test
removes the issue altogether.I will implement setting the tests as a workaround, but I am not sure if this is an underlying libxml2 issue, or something specific to the crate.
Thoughts?
The text was updated successfully, but these errors were encountered: