From 52fdf57a86cb556640e5ebcc234bc826ff249546 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 22 Nov 2022 17:55:02 +0100 Subject: prog: don't decompress more than 1 image at a time --- prog/mutation.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prog/mutation.go b/prog/mutation.go index 9b17532c7..86114f700 100644 --- a/prog/mutation.go +++ b/prog/mutation.go @@ -9,6 +9,7 @@ import ( "math" "math/rand" "sort" + "sync" ) // Maximum length of generated binary blobs inserted into the program. @@ -382,10 +383,17 @@ func (t *BufferType) mutate(r *randGen, s *state, arg Arg, ctx ArgCtx) (calls [] return } +var imageMu sync.Mutex + func (r *randGen) mutateImage(image []byte) (data []byte, retry bool) { if len(image) == 0 { return image, true } + // Don't decompress more than one image at a time + // since it can consume lots of memory. + // Reconsider when/if we move mutation to the host process. + imageMu.Lock() + defer imageMu.Unlock() data, err := Decompress(image) if err != nil { panic(fmt.Sprintf("could not decompress data: %v", err)) -- cgit mrf-deployment