mirage / mirage-entropy

Entropy driver for MirageOS -- this has been imported into https://github.com/mirage/mirage-crypto
http://openmirage.org/
BSD 2-Clause "Simplified" License
12 stars 11 forks source link

slow memory leak in fortuna? #25

Closed avsm closed 9 years ago

avsm commented 9 years ago
Cannot handle page request order 0!
Fatal error: exception Out of memory
Raised by primitive operation at file "bigarray.ml", line 120, characters 4-39
Called from file "lib/cstruct.ml", line 45, characters 25-56
Called from file "src/fortuna.ml", line 116, characters 6-39
Called from file "list.ml", line 73, characters 12-15
Called from file "src/core/lwt_sequence.ml", line 149, characters 31-47
Called from file "lib/main.ml", line 66, characters 10-62
Called from file "main.ml", line 125, characters 2-77
Mirage exiting with status 2
Do_exit called!

Leaving an SSL unikernel overnight showed this in the console the next day. Is the RNG gathering trapping memory?

hannesm commented 9 years ago

was there any network traffic involved? how much memory did the virtual machine have (is there an easy and fast way to reproduce?)

talex5 commented 9 years ago

BTW, are there any recommended tools too track down leaks in unikernels?

pqwy commented 9 years ago

I don't have my Xen VM with me, so can't test out directly until the end of the week.

I did swap OS from mirage-xen with the one from mirage-unix, though, and attaching the entropy harvesting in Entropy_xen to it and feeding into Fortuna exhibits constant memory behavior in some seriously tight loops. There is a possibility that this is different on Xen, since the event loop is slightly different there, but my current hypothesis would be that something else is eating up the memory and that entropy is simply the first thing to hit an out-of-memory condition, being the first to run after a wakeup.

Both the entropy harvesting and the accumulator injection were written with reducing allocations in mind, and the code path is meant to cons up only a few small and short lived objects.

I might be wrong here, but I would suggest exploring what else has changed since the last time this setup was working.

hannesm commented 9 years ago

closing this issue, there were leaks in TCP/IP and also in mirage-net-unix. Please reopen if there's evidence this is actually an issue in mirage-entropy.