Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile printer can stack overflow #30365

Closed
Keno opened this issue Dec 12, 2018 · 8 comments
Closed

Profile printer can stack overflow #30365

Keno opened this issue Dec 12, 2018 · 8 comments

Comments

@Keno
Copy link
Member

Keno commented Dec 12, 2018

julia> Profile.print(noisefloor=0.1)
ERROR: StackOverflowError:
Stacktrace:
 [1] (::getfield(Profile, Symbol("#cleanup!#21")))(::Profile.StackFrameTree{Base.StackTraces.StackFrame}) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:552
 [2] foreach(::getfield(Profile, Symbol("#cleanup!#21")), ::Base.ValueIterator{Dict{Base.StackTraces.StackFrame,Profile.StackFrameTree{Base.StackTraces.StackFrame}}}) at ./abstractarray.jl:1862
 ... (the last 2 lines are repeated 9990 more times)
 [19983] (::getfield(Profile, Symbol("#cleanup!#21")))(::Profile.StackFrameTree{Base.StackTraces.StackFrame}) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:552
 [19984] tree!(::Profile.StackFrameTree{Base.StackTraces.StackFrame}, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}, ::Bool) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:555
 [19985] tree(::Base.TTY, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}, ::Int64, ::Profile.ProfileFormat) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:585
 [19986] print(::Base.TTY, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}, ::Profile.ProfileFormat, ::Symbol) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:147
 [19987] (::getfield(Profile, Symbol("#kw##print")))(::NamedTuple{(:noisefloor,),Tuple{Float64}}, ::typeof(Profile.print), ::Base.TTY, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:134
 [19988] #print#5(::Base.Iterators.Pairs{Symbol,Float64,Tuple{Symbol},NamedTuple{(:noisefloor,),Tuple{Float64}}}, ::Function, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}) at /home/keno/julia-1.0/usr/share/julia/stdlib/v1.1/Profile/src/Profile.jl:164
 [19989] #print at ./none:0 [inlined] (repeats 3 times)
@timholy
Copy link
Member

timholy commented Dec 12, 2018

Do you have a reproducible test case? It seems to suggest there are circumstances where one can get a cycle in the tree, which shouldn't happen. Either that, or you're profiling some really deeply nested code?

@fredrikekre
Copy link
Member

Maybe #28648 is this stackoverflow + #17109 then?

@Keno
Copy link
Member Author

Keno commented Dec 12, 2018

I don't really have a reproducer. I was profiling some compiler stuff. It is fairly deeply nested, but not eggregiously so. Also goes away if I reduce the profile interval.

@timholy
Copy link
Member

timholy commented Dec 12, 2018

Maybe just Profile.retrieve and save somehow so it's easier to farm out to others or tackle later.

@vtjnash
Copy link
Member

vtjnash commented Dec 12, 2018

I don't think this is #28648. A stack depth of 9990 doesn't seem all that deep (remember too that this is after expanding inlining frames too, although after dropping C frames) and that's certainly plausible within an inference run. I'm just a bit surprised that 19989 moderate-sized frames would overflow the stack, since cleanup! here should be a pretty simple function.

@Keno
Copy link
Member Author

Keno commented Dec 30, 2018

Seems to show up on the buildbots too: https://build.julialang.org/#/builders/13/builds/458/steps/2/logs/stdio

@vtjnash
Copy link
Member

vtjnash commented Jan 17, 2019

julia> using Profile
julia> f(a) = g(a); g(a) = h(a); h(a) = i(a); i(a) = j(a); j(a) = k(a); k(a) = l(a); l(a) = m(a); m(a) = (a == 0 ? "$a" : f(a - 1));
julia> @profile for i = 1:10; f(10000); end

julia> Profile.print()
┌ Warning: The profile data buffer is full; profiling probably terminated
│ before your program finished. To profile for longer runs, call
│ `Profile.init()` with a larger buffer and/or larger delay.
└ @ Profile /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:312
ERROR: StackOverflowError:
Stacktrace:
 [1] (::getfield(Profile, Symbol("#cleanup!#21")))(::Profile.StackFrameTree{Base.StackTraces.StackFrame}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:552
 [2] foreach(::getfield(Profile, Symbol("#cleanup!#21")), ::Base.ValueIterator{Dict{Base.StackTraces.StackFrame,Profile.StackFrameTree{Base.StackTraces.StackFrame}}}) at ./abstractarray.jl:1868
 ... (the last 2 lines are repeated 9276 more times)
 [18555] (::getfield(Profile, Symbol("#cleanup!#21")))(::Profile.StackFrameTree{Base.StackTraces.StackFrame}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:552
 [18556] tree!(::Profile.StackFrameTree{Base.StackTraces.StackFrame}, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}, ::Bool) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:555
 [18557] tree(::Base.TTY, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}, ::Int64, ::Profile.ProfileFormat) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:585
 [18558] print(::Base.TTY, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}, ::Profile.ProfileFormat, ::Symbol) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:147
 [18559] print(::Base.TTY, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:134
 [18560] #print#5(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Array{UInt64,1}, ::Dict{UInt64,Array{Base.StackTraces.StackFrame,1}}) at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:164
 [18561] print at /data/vtjnash/julia/usr/share/julia/stdlib/v1.2/Profile/src/Profile.jl:164 [inlined] (repeats 2 times)

@vtjnash
Copy link
Member

vtjnash commented May 8, 2019

fixed by #31893

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants