fwsGonzo / libriscv

The fastest RISC-V sandbox
BSD 3-Clause "New" or "Revised" License
522 stars 46 forks source link

Potential memory leak #154

Closed fwsGonzo closed 3 weeks ago

fwsGonzo commented 3 weeks ago

libfuzzer quits after several hours of fuzzing, saying out-of-memory because of RSS reaching the default 2GB limit. Either it's a small memory leak in libriscv, or it's just the fuzzer growing over time and then reaching the limit.

Something to investigate.

fwsGonzo commented 3 weeks ago
$ valgrind --tool=memcheck ./rvlinux ../binaries/stream-rv64gc 
==953126== Memcheck, a memory error detector
==953126== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==953126== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==953126== Command: ./rvlinux ../binaries/stream-rv64gc
==953126== 
==953126== Warning: set address range perms: large range [0x59c87000, 0xd6c88000) (defined)
-------------------------------------------------------------
STREAM version $Revision: 5.10 $
-------------------------------------------------------------
This system uses 8 bytes per array element.
-------------------------------------------------------------
Array size = 10000000 (elements), Offset = 0 (elements)
Memory per array = 76.3 MiB (= 0.1 GiB).
Total memory required = 228.9 MiB (= 0.2 GiB).
Each kernel will be executed 10 times.
 The *best* time for each kernel (excluding the first iteration)
 will be used to compute the reported bandwidth.
-------------------------------------------------------------
Your clock granularity/precision appears to be 1 microseconds.
Each test below will take on the order of 658407 microseconds.
   (= 658407 clock ticks)
Increase the size of the arrays if this shows that
you are not getting at least 20 clock ticks per test.
-------------------------------------------------------------
WARNING -- The above is only a rough guideline.
For best results, please be sure you know the
precision of your system timer.
-------------------------------------------------------------
Function    Best Rate MB/s  Avg time     Min time     Max time
Copy:             418.0     0.384084     0.382810     0.385183
Scale:            232.0     0.692043     0.689707     0.700342
Add:              266.5     0.902748     0.900602     0.906978
Triad:            241.0     0.998334     0.995977     1.003555
-------------------------------------------------------------
Solution Validates: avg error less than 1.000000e-13 on all three arrays
-------------------------------------------------------------
>>> Program exited, exit code = 0 (0x0)
Instructions executed: 2787589398  Runtime: 34098.848ms  Insn/s: 82mi/s
Pages in use: 110 (440 kB virtual memory, total 1768 kB)
==953126== Warning: set address range perms: large range [0x59c87000, 0xd6c87000) (noaccess)
==953126== 
==953126== HEAP SUMMARY:
==953126==     in use at exit: 0 bytes in 0 blocks
==953126==   total heap usage: 1,094,169 allocs, 1,094,169 frees, 248,270,319 bytes allocated
==953126== 
==953126== All heap blocks were freed -- no leaks are possible
==953126== 
==953126== For lists of detected and suppressed errors, rerun with: -s
==953126== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Seems like just libfuzzer growing over time.