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

Make exit status interpretable by CommandConfigurator #2723

Merged
merged 6 commits into from
Nov 27, 2024

Conversation

momvart
Copy link
Contributor

@momvart momvart commented Nov 25, 2024

Closes #2718

@tokatoka
Copy link
Member

looks good

@tokatoka
Copy link
Member

can you fix the error from the windows too

@momvart
Copy link
Contributor Author

momvart commented Nov 25, 2024

can you fix the error from the windows too

Can you help me how I can suppress doctest? Somehow that it doesn't run on windows at least.

@tokatoka
Copy link
Member

you can't use use crate::std::os::unix::process::ExitStatusExt; without guarding it with cfg[(unix)] because it won't work on windows

@momvart
Copy link
Contributor Author

momvart commented Nov 26, 2024

you can't use use crate::std::os::unix::process::ExitStatusExt; without guarding it with cfg[(unix)] because it won't work on windows

I think it is due to the doc block on top of it that doesn't build successfully on windows. The trait doesn't exist in windows but building the docs on windows makes it appear and fail the build. Maybe we should make the doc only appear on UNIX only.

@tokatoka

This comment was marked as outdated.

@momvart
Copy link
Contributor Author

momvart commented Nov 26, 2024

wait can you put #[cfg(all(feature = "std", target_os = "linux"))] in executors/mod.rs? this code won't work on non-unix or non std then you can delete all #[cfg(all(feature = "std", target_os = "linux"))] inside this command.rs

There is already one

#[cfg(all(feature = "std", any(unix, doc)))]
pub mod command;

Do you want me to restrict it further to linux? What to do about doc? Should I remove that so that the docs only appears in UNIX?

@tokatoka
Copy link
Member

There is already one

ah never mind i was not aware of that

@tokatoka
Copy link
Member

Sorry i didn't understand the real issue previously.

Maybe we should make the doc only appear on UNIX only.

Can you do this?

@tokatoka
Copy link
Member

diff --git a/libafl/src/executors/command.rs b/libafl/src/executors/command.rs
index 5eb5f087..ac1fe6d0 100644
--- a/libafl/src/executors/command.rs
+++ b/libafl/src/executors/command.rs
@@ -801,7 +801,7 @@ impl CommandExecutorBuilder {
 ///     MyExecutor.into_executor(())
 /// }
 /// ```
-#[cfg(all(feature = "std", any(unix, doc)))]
+#[cfg(all(feature = "std", unix))]
 pub trait CommandConfigurator<I, C = Child>: Sized {
     /// Get the stdout
     fn stdout_observer(&self) -> Option<Handle<StdOutObserver>> {
diff --git a/libafl/src/executors/mod.rs b/libafl/src/executors/mod.rs
index 993a85fe..d8c9c345 100644
--- a/libafl/src/executors/mod.rs
+++ b/libafl/src/executors/mod.rs
@@ -5,7 +5,7 @@ use alloc::vec::Vec;
 use core::{fmt::Debug, time::Duration};

 pub use combined::CombinedExecutor;
-#[cfg(all(feature = "std", any(unix, doc)))]
+#[cfg(all(feature = "std", unix))]
 pub use command::CommandExecutor;
 pub use differential::DiffExecutor;
 #[cfg(all(feature = "std", feature = "fork", unix))]
@@ -23,7 +23,7 @@ pub use with_observers::WithObservers;
 use crate::{observers::ObserversTuple, state::UsesState, Error};

 pub mod combined;
-#[cfg(all(feature = "std", any(unix, doc)))]
+#[cfg(all(feature = "std", unix))]
 pub mod command;
 pub mod differential;
 #[cfg(all(feature = "std", feature = "fork", unix))]

Merge diff to your branch please. It should work

@tokatoka
Copy link
Member

wait. i'll just open a pr to fix this... the cfgs in this file is a total mess..

@momvart
Copy link
Contributor Author

momvart commented Nov 26, 2024

the cfgs in this file is a total mess..

Agreed.

I pushed your changes BTW. Maybe you can apply the refactor after merging this PR.

@tokatoka
Copy link
Member

no what i thought was useless was necessary for macos stuff..
i'll merge this if ci is good

@tokatoka
Copy link
Member

there's a bit more to fix.
can you fix the doc?

@tokatoka tokatoka merged commit 0d0bbf0 into AFLplusplus:main Nov 27, 2024
102 of 103 checks passed
@tokatoka
Copy link
Member

thank you.

@momvart
Copy link
Contributor Author

momvart commented Nov 27, 2024

Anyway, I think refactoring is required for these platform-specific structures. The code is very brittle even for these minor changes.

@momvart momvart deleted the 2718-cmd-executor-exit-kind branch November 27, 2024 19:44
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.

Non-zero exit code is considered ok in CommandExecutor
2 participants