Skip to content

Commit

Permalink
These tests didn't do what you thought they did
Browse files Browse the repository at this point in the history
The `rng` assignment inside the closure was actually reassigning the local `rng`,
which would then occaisionally segfault, because `RandomDevice` is immutable,
so there's nothing that actually rooted it to the device object.

Side note: Somebody should probably add assertions that the various things
we're trying to protect by rooting them in the context object are actually mutable.
However, I've spent too much time on this already so I'll leave that to somebody else ;).
  • Loading branch information
Keno authored Oct 27, 2020
1 parent a5f62eb commit aac2353
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ let
entropy = MbedTLS.Entropy()

function entropy_func(buf)
rng = RandomDevice()
buf[:] = rand(rng, UInt8, length(buf))
buf[:] = rand(RandomDevice(), UInt8, length(buf))
return Cint(length(buf))
end

Expand Down Expand Up @@ -134,8 +133,7 @@ let
entropy = MbedTLS.Entropy()

function entropy_func(buf)
rng = RandomDevice()
buf[:] = rand(rng, UInt8, length(buf))
buf[:] = rand(RandomDevice(), UInt8, length(buf))
return Cint(length(buf))
end

Expand Down

0 comments on commit aac2353

Please sign in to comment.