Skip to content

Update lib.rs #3160

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

Closed
wants to merge 1 commit into from
Closed

Update lib.rs #3160

wants to merge 1 commit into from

Conversation

20urc3
Copy link
Contributor

@20urc3 20urc3 commented Apr 14, 2025

I added the new error variants to the Error enum:

  • Configuration - For errors related to incorrect configuration settings
  • Compilation - For errors related to code compilation issues
  • System - For system call failures and resource allocation problems
  • Version - For version compatibility issues

And added their corresponding constructor methods for each new error type, following the same pattern as the existing constructors in the library.

I added the new error variants to the Error enum:
- Configuration - For errors related to incorrect configuration settings
- Compilation - For errors related to code compilation issues
- System - For system call failures and resource allocation problems
- Version - For version compatibility issues

and added their corresponding constructor methods for each new error type, following the same pattern as the existing constructors in the library.
@20urc3 20urc3 mentioned this pull request Apr 14, 2025
/// Compilation-related errors
Compilation(String, ErrorBacktrace),
/// System call or resource allocation failures
System(String, ErrorBacktrace),
Copy link
Member

Choose a reason for hiding this comment

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

This is almost always identical to OsError, right? Maybe make OsError's io::Error be optional, instead

/// System call or resource allocation failures
System(String, ErrorBacktrace),
/// Version compatibility issues
Version(String, ErrorBacktrace),
Copy link
Member

Choose a reason for hiding this comment

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

Does this ever happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well yes

  • System(String, ErrorBacktrace) → Err(Error::system("The fuzzing target reports that the shm_open() call failed.")) and similar system error messages
  • Version(String, ErrorBacktrace) → Err(Error::version("The -c cmplog target was instrumented with an too old AFL++ version, you need to recompile it.")) and the other version error message

Copy link
Member

Choose a reason for hiding this comment

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

I'd say it's fine to do
System(String, ErrorBacktrace) → Err(Error::os_error(None, "The fuzzing target reports that the shm_open() call failed.")) or os_error_str
(Error::illegal_state("The -c cmplog target was instrumented with an too old AFL++ version, you need to recompile it.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lgtm will do that

@@ -341,6 +341,14 @@ pub enum Error {
InvalidCorpus(String, ErrorBacktrace),
/// Error specific to a runtime like QEMU or Frida
Runtime(String, ErrorBacktrace),
/// Configuration errors, such as incorrect map sizes
Configuration(String, ErrorBacktrace),
Copy link
Member

Choose a reason for hiding this comment

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

is this different toIllegalArgument?

@domenukk
Copy link
Member

Do you have use cases for each of those?

@20urc3
Copy link
Contributor Author

20urc3 commented Apr 16, 2025

Do you have use cases for each of those?

Those were deduced from fn report_error_and_exit(status: i32)

FS_ERROR_MAP_SIZE - Configuration issue
FS_ERROR_MAP_ADDR - Compilation issue
FS_ERROR_SHM_OPEN, FS_ERROR_SHMAT, FS_ERROR_MMAP - System-level issues
FS_ERROR_OLD_CMPLOG, FS_ERROR_OLD_CMPLOG_QEMU - Version compatibility issues
  • Configuration(String, ErrorBacktrace) → Err(Error::configuration("AFL_MAP_SIZE is not set and fuzzing target reports that the required size is very large. Solution: Run the fuzzing target stand-alone..."))
  • Compilation(String, ErrorBacktrace) → Err(Error::compilation("The fuzzing target reports that hardcoded map address might be the reason the mmap of the shared memory failed. Solution: recompile the target..."))
  • System(String, ErrorBacktrace) → Err(Error::system("The fuzzing target reports that the shm_open() call failed.")) and similar system error messages
  • Version(String, ErrorBacktrace) → Err(Error::version("The -c cmplog target was instrumented with an too old AFL++ version, you need to recompile it.")) and the other version error message

@domenukk
Copy link
Member

Yeah.. I would prefer to map these on existing error codes, see my comment above

@20urc3
Copy link
Contributor Author

20urc3 commented Apr 16, 2025

Yeah.. I would prefer to map these on existing error codes, see my comment above

Ok for OSError instead of CompilationError, and where is defined toIllegalArgument?
For the System/Version i dont see existing error that correspond.

@domenukk
Copy link
Member

Status?

@20urc3 20urc3 closed this May 26, 2025
@20urc3 20urc3 deleted the patch-2 branch May 26, 2025 15:26
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