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

Open to "resettable" lazy_static PR? #164

Closed
smoelius opened this issue Jan 26, 2020 · 2 comments
Closed

Open to "resettable" lazy_static PR? #164

smoelius opened this issue Jan 26, 2020 · 2 comments

Comments

@smoelius
Copy link
Member

lazy_static variables present a problem when fuzzing with AFL in persistent mode (the default for afl.rs). This fact was observed by @pedrocr in #152:

Apparently lazy_static is something that needs to be handled carefully for afl. It ends up only being initialized inside the loop instead of only once. It's easy to work around in this codebase but it may be something that needs to be fixed more fully for other codebases to work well.

To address this problem, I wrote a "resettable" version of lazy_static. Intuitively, the resettable version collects all initialized lazy_static variables in a linked list. A call to lazy_static::lazy::reset() walks the linked list and uninitializes each variable.

An example of its use can be found here.

The lazy_static maintainers did not want to merge this, as it complicates the get operation. (Their position is understandable.)

So, would you be open to a PR that does the following?

  • Adds a call to lazy_static::lazy::reset() between these two lines, guarded by a reset-lazy-static feature.
  • Adds a section to the README explaining how one can use cargo's patching mechanism to substitute the resettable version of lazy_static for the standard one.

I regard to the second bullet, I think it would be better if the README referred readers to a rust-fuzz repository. So, I would offer to let rust-fuzz hold the "official" resettable lazy_static. Please let me know if this is something that you would like to do.

@frewsxcv
Copy link
Member

hey @smoelius, i don't have much time nowadays to maintain afl.rs. your proposed change sounds good to me! i just sent you an invite to the rust-fuzz organization if you're interested in making any changes to afl.rs

@smoelius
Copy link
Member Author

Great and thanks! I will submit the changes soon.

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

No branches or pull requests

2 participants