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

Remove feature flags #681

Merged
merged 6 commits into from
Jul 19, 2017
Merged

Remove feature flags #681

merged 6 commits into from
Jul 19, 2017

Conversation

Susurrus
Copy link
Contributor

@Susurrus Susurrus commented Jul 17, 2017

These are vestiges of the initial push to get this working on Rust 1.0. These feature flags are undocumented and so hard to discover (only learned about them today!), prevent functions being included that should be and this also affects documentation on docs.rs, and none of the features are tested in CI and the execvpe has been broken for forever.

The solution is to conditionally compile everything supported for a given platform and do away completely with the feature flags. The execvpe function is completely removed as it's not available for *nix platforms in libc and is already broken, so no loss removing it. We'll add it back once it's back in libc (rust-lang/libc#670).

Closes #98.
Closes #206.
Closes #306.
Closes #308.

@asomers
Copy link
Member

asomers commented Jul 17, 2017

Coincidentally, I first learned of those feature flags today, too. I agree with getting rid of them. Could you also change test_signalfd.rs into a normal test file? And there are also some feature gates in test_unistd.rs and sys/test_uio.rs to remove.

@Susurrus
Copy link
Contributor Author

I'm working on fixing the tests but I get a "main function not found" when I "fix" things. You have this problem before?

@Susurrus Susurrus force-pushed the rem_features branch 2 times, most recently from 4cb46ad to 4c8c94f Compare July 17, 2017 05:35
@Susurrus
Copy link
Contributor Author

Nvm, figured it out. Weird we have mount and signalfd tests using a custom test harness instead of the main one. This is some old code..

@Susurrus
Copy link
Contributor Author

And this needs a CHANGELOG before it can be merged, but I'm working on getting CI passing first.

@Susurrus
Copy link
Contributor Author

Android failures are because of missing libc items (see rust-lang/libc#671), but I'll probably just disable signalfd on android so this can be part of the current release.

@Susurrus
Copy link
Contributor Author

There are ECHILD errors from running the tests, which I can also produce locally, so I'll need to figure those out as well.

@Susurrus Susurrus force-pushed the rem_features branch 2 times, most recently from 0d39c9d to fcc22f2 Compare July 17, 2017 14:25
@Susurrus
Copy link
Contributor Author

@asomers Want to take a look-see over this for me, as I think the new signalfd test should be good but I'm not too comfortable with fork and would appreciate a second pair of eyes on it? Should be ready to go if it looks good to you.

This was referenced Jul 17, 2017
@@ -0,0 +1,52 @@
#[cfg(target_os = "linux")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this line redundant with test/sys/mod.rs:5 ?

mask.thread_block().unwrap();

// Start a child process
match unistd::fork() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you should fork here. For one thing, cargo's test harness has deadlocks when a multithreaded test program forks. That's why I had to add std::process:exit(0) all over the place. For another thing, it's not necessary. You can just create the eventfd and send the signal all from the same thread, just like the old test did.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember why I was doing this, because if I didn't I saw errors like "process didn't exit successfully (signal: 10)" even just running my test by itself. This is ECHILD, which states there are no child processes. Would you have another suggestion rather than forking?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ECHILD is an errno, not a signal. Signal 10, on Linux, is SIGUSR1. It sounds like you weren't correctly blocking the signal. I can take a look at it, if you want.


// Set up a signalfd to listen for SIGUSR1 on this thread
let mut mask = SigSet::empty();
mask.add(SIGUSR1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGUSR1 is a global resource, so this test will conflict with any other test that does anything with it. I dealt with that in PR #638 by creating a mutex to protect SIGUSR2. You should probably do the same for SIGUSR1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to use SIGUSR2, but I actually think this implementation isn't quite right. According to [this](https://stackoverflow.com/questions/11679568/signal-handling-with-multiple-threads-in-linux#11679770] signal disposition is shared across all threads in a process. So I think we should actually have a SIGNAL_MTX and not one specific to each signal.

@Susurrus
Copy link
Contributor Author

Thanks for the review, @asomers, everything should be addressed now!

Note that I b roadened the SIGUSR2_MTX to a general SIGNAL_MTX because depending on how signal handling is modified, it might not be updated in one test in a way that doesn't clobber the signal mask in another test. So instead of worrying about that, just make it general to all signal handling. This also makes it more in line with the rest of the mutexes which are pretty broad.

Also, I wanted to note that this includes a commit to fix unused imports introduced by you @asomers in 2cd4420. You might be running an older version of Rust that doesn't output warnings about unused variables in tests by default, which is why this was easy to miss. Might be worth updating Rust depending on your specific dev needs!

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from that one kill/raise typo, it all looks good to me. Fix that and r+ asomers

BTW, I submitted a PR to libc last night to support preadv/pwritev on more platforms. That can be a nix 0.10.0 addition.

// Send a SIGUSR1 signal to the current process. Note that this uses `raise` instead of `kill`
// because `kill` with `getpid` isn't correct during multi-threaded execution like during a
// cargo test session. Instead use `raise` which does the correct thing by default.
raise(signal::SIGUSR1).ok().expect("Error: Kill Failed");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Kill/raise

Susurrus added 4 commits July 18, 2017 13:04
Note that this is now only available for Linux as support is missing in libc
for Android (see rust-lang/libc#671).

As part of this work the SIGUSR2 signal mutex was altered to be a general
signal mutex. This is because all signal handling is shared across all threads
in the Rust test harness, so if you alter one signal, depending on whether it's
additive or may overwrite the mask for other signals, it could break the other
ones. Instead of putting this on the user, just broaden the scope of the mutex
so that any altering of signal handling needs to use it.
It was broken when enabled, and currently the libc definition is only
available for windows. This will be re-added when a new libc is released
that supports it across all available platforms
@Susurrus
Copy link
Contributor Author

Cool, thanks for reviewing it!

As for supporting preadv/pwritev on more platforms, can you open an issue for it? It'd be great to have more mentored/good-first-bug issues.

bors r+ asomers

bors bot added a commit that referenced this pull request Jul 18, 2017
681: Remove feature flags r=Susurrus

These are vestiges of the initial push to get this working on Rust 1.0. These feature flags are undocumented and so hard to discover (only learned about them today!), prevent functions being included that should be and this also affects documentation on docs.rs, and none of the features are tested in CI and the `execvpe` has been broken for forever.

The solution is to conditionally compile everything supported for a given platform and do away completely with the feature flags. The `execvpe` function is completely removed as it's not available for *nix platforms in libc and is already broken, so no loss removing it. We'll add it back once it's back in libc (rust-lang/libc#670).

Closes #98.
Closes #206.
Closes #306.
Closes #308.
@bors
Copy link
Contributor

bors bot commented Jul 19, 2017

Build failed

@asomers
Copy link
Member

asomers commented Jul 19, 2017

We hit the test_double_close timeout on powerpc again. But we also had failures in the epoll tests on x86_64. I haven't personally seen that one yet.

@Susurrus
Copy link
Contributor Author

I'm thinking it's time to deprecate powerpc to Tier 2 as you suggested, and I propose we do that for the 0.9 release so we aren't promising too much to our customers.

@Susurrus
Copy link
Contributor Author

I'm seeing those epoll failures on #686 as well....Hmmm.

@Susurrus
Copy link
Contributor Author

I'm re-running master by itself to see what's going on: https://travis-ci.org/nix-rust/nix/builds/254708956

@Susurrus Susurrus mentioned this pull request Jul 19, 2017
@Susurrus
Copy link
Contributor Author

bors r+ asomers

bors bot added a commit that referenced this pull request Jul 19, 2017
681: Remove feature flags r=Susurrus

These are vestiges of the initial push to get this working on Rust 1.0. These feature flags are undocumented and so hard to discover (only learned about them today!), prevent functions being included that should be and this also affects documentation on docs.rs, and none of the features are tested in CI and the `execvpe` has been broken for forever.

The solution is to conditionally compile everything supported for a given platform and do away completely with the feature flags. The `execvpe` function is completely removed as it's not available for *nix platforms in libc and is already broken, so no loss removing it. We'll add it back once it's back in libc (rust-lang/libc#670).

Closes #98.
Closes #206.
Closes #306.
Closes #308.
@bors
Copy link
Contributor

bors bot commented Jul 19, 2017

@bors bors bot merged commit bee13c8 into nix-rust:master Jul 19, 2017
@Susurrus Susurrus deleted the rem_features branch July 19, 2017 14:05
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

Successfully merging this pull request may close these issues.

2 participants