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

Passing options by environment variables may set them too late and is not portable #8

Open
Shnatsel opened this issue Oct 24, 2018 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Shnatsel
Copy link
Owner

Currently libdiffuzz switches to non-deterministic mode after reading an environment variable from a function called from link-time "constructors" section:

libdiffuzz/src/lib.rs

Lines 31 to 33 in f0c7a8f

#[cfg_attr(any(target_os = "macos", target_os = "ios"), link_section = "__DATA,__mod_init_func")]
#[cfg_attr(not(any(target_os = "macos", target_os = "ios")), link_section = ".ctors")]
pub static CONSTRUCTOR: extern fn() = libdiffuzz_init_config;

This is not a great idea for two reasons:

  1. This is not portable. This is already taking different codepaths depending on whether it's on Linux/BSD or macOS. Windows is currently not supported. What's worse, there is no way to tell if this actually works on your platform or not!
  2. This may kick in too late and miss initializing some heap-allocated memory in other libraries with similar hooks, so libdiffuzz will fail to expose some errors.
@Shnatsel Shnatsel added bug Something isn't working help wanted Extra attention is needed labels Oct 24, 2018
@Shnatsel
Copy link
Owner Author

I'd prefer to fix this by building two different dynamic libraries, libdiffuzz and libdiffuzz-random, with the appropriate mode hardcoded in each.

There is also dynamic setup of the amount of memory to over-allocate, but that's a fairly obscure feature which can be moved into a compile-time parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant