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

Save corpus continuously while fuzzing; add TestSimplified and ErrorEvent events; change event system #1048

Closed
wants to merge 1 commit into from

Conversation

samalws-tob
Copy link
Collaborator

@samalws-tob samalws-tob commented May 18, 2023

This PR:

  • Adds an event handler which continuously saves corpus as new coverage/reproducers are discovered (Save inputs as soon as possible #1045)
    • Makes the NewCoverage event include the list of transactions as part of the event, since this is needed when saving corpus info
    • Unsimplified tests are saved with the prefix unsimplified-
  • Adds a TestSimplified event which is called whenever a test is fully simplified (so that the simplified transactions can be saved)
  • Adds an ErrorEvent event which is called when something goes wrong during event handling
  • Changes the event system to be based on an IORef [event -> IO ()] instead of channels. Channels were annoying because you would have to duplicate the channel and make a new thread for each event handler
  • Adds spawnThread and awaitThreads helper functions to spawn temporary threads and wait for all threads to be finished (in this PR used to save files, so that the worker doesn't have to wait while the file is saved)
  • Takes the absolute value of hash when deciding corpus filenames in order to avoid weird -12345.txt files

(Most of these changes are just solutions to problems I encountered while trying to make echidna save corpus while fuzzing)

Replaces #1047

Copy link
Member

@arcz arcz left a comment

Choose a reason for hiding this comment

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

Great work! We can do a few improvements to make it more robust.

lib/Echidna/Async.hs Outdated Show resolved Hide resolved
lib/Echidna/Async.hs Outdated Show resolved Hide resolved
lib/Echidna/Output/Corpus.hs Outdated Show resolved Hide resolved
lib/Echidna/Types/Campaign.hs Outdated Show resolved Hide resolved
@samalws-tob samalws-tob force-pushed the saveCoverageEarly4 branch 5 times, most recently from 42b0ba0 to c0e3206 Compare May 19, 2023 17:49
@samalws-tob samalws-tob changed the title Save corpus continuously while fuzzing; add TestSimplified event; change event system Save corpus continuously while fuzzing; add TestSimplified and ErrorEvent events; change event system May 19, 2023
lib/Echidna/Output/Corpus.hs Outdated Show resolved Hide resolved

-- mainly for handling events, but can be used for any purpose
-- `wait` is called on this group before echidna closes
, threadGroup :: ThreadGroup
Copy link
Member

Choose a reason for hiding this comment

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

We should move this to spawnListener and make all the handlers spawned async

Copy link
Collaborator Author

@samalws-tob samalws-tob Sep 29, 2023

Choose a reason for hiding this comment

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

Not sure I understand what you mean here? I got rid of spawnListener, and all handlers are spawned async now

lib/Echidna/Types/Campaign.hs Outdated Show resolved Hide resolved
@@ -127,6 +131,8 @@ main = withUtf8 $ withCP65001 $ do

tests <- readIORef testsRef

ThreadGroup.wait threadGroup
Copy link
Member

Choose a reason for hiding this comment

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

We should move this to spawnListener before putMVar stopVar ()

@samalws-tob samalws-tob force-pushed the saveCoverageEarly4 branch 3 times, most recently from 8a2fca4 to e3b86cd Compare September 29, 2023 17:54
@arcz
Copy link
Member

arcz commented Jan 18, 2024

Done in #1167.

@arcz arcz closed this Jan 18, 2024
@arcz arcz deleted the saveCoverageEarly4 branch January 18, 2024 21:21
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