Skip to content

Commit 4b6a8ae

Browse files
committed
Ensure a frame can't be recycled multiple times
1 parent b3bc13e commit 4b6a8ae

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/commands.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function unwind_exception(frame::Frame, exc)
283283
frame.framedata.last_exception[] = exc
284284
return frame
285285
end
286-
# recycle(frame)
286+
recycle(frame)
287287
frame = caller(frame)
288288
frame === nothing || (frame.callee = nothing)
289289
end

src/construct.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ rather than recursed into via the interpreter.
2020
"""
2121
const compiled_methods = Set{Method}()
2222

23-
const junk = FrameData[] # to allow re-use of allocated memory (this is otherwise a bottleneck)
24-
recycle(frame) = push!(junk, frame.framedata)
23+
const junk = Base.IdSet{FrameData}() # to allow re-use of allocated memory (this is otherwise a bottleneck)
24+
recycle(frame) = push!(junk, frame.framedata) # using an IdSet ensures that a frame can't be added twice
2525

2626
const empty_svec = Core.svec()
2727

@@ -238,7 +238,8 @@ function prepare_framedata(framecode, argvals::Vector{Any})
238238
ng = isa(ssavt, Int) ? ssavt : length(ssavt::Vector{Any})
239239
nargs = length(argvals)
240240
if !isempty(junk)
241-
olddata = pop!(junk)
241+
olddata = first(junk)
242+
delete!(junk, olddata)
242243
locals, ssavalues, sparams = olddata.locals, olddata.ssavalues, olddata.sparams
243244
exception_frames, last_reference = olddata.exception_frames, olddata.last_reference
244245
last_exception = olddata.last_exception

0 commit comments

Comments
 (0)