Skip to content

Commit

Permalink
Move test of stackoverflow with close(::Channel) to stack_overflow.jl (
Browse files Browse the repository at this point in the history
…JuliaLang#49702) (#108)

Per @vtjnash's comment here:
https://github.com/JuliaLang/julia/pull/49508/files/bca5ac79d04fb2a95f3b9a7b7448fe5b478f950b#r1186161259

> the handling of this error is quite bad and sometimes ends up breaking
> the process (as I found out today trying to debug something completely
> unrelated)

This is a Tests-only PR
  • Loading branch information
NHDaly authored Nov 8, 2023
1 parent 6afe64e commit 8af2576
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 0 additions & 17 deletions test/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -633,20 +633,3 @@ end
@test n_avail(c) == 0
end
end

# Issue #49507: stackoverflow in type inference caused by close(::Channel, ::Exception)
@testset "close(::Channel, ::StackOverflowError)" begin
ch = let result = Channel()
foo() = try
foo()
catch e;
close(result, e)
end

foo() # This shouldn't fail with an internal stackoverflow error in inference.

result
end

@test (try take!(ch) catch e; e; end) isa StackOverflowError
end
17 changes: 17 additions & 0 deletions test/stack_overflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,20 @@ let exename = Base.julia_cmd()
@show readchomperrors(`$exename -e "f() = f(); f()"`)
@show readchomperrors(`$exename -e "f() = f(); fetch(@async f())"`)
end

# Issue #49507: stackoverflow in type inference caused by close(::Channel, ::Exception)
@testset "close(::Channel, ::StackOverflowError)" begin
ch = let result = Channel()
foo() = try
foo()
catch e;
close(result, e)
end

foo() # This shouldn't fail with an internal stackoverflow error in inference.

result
end

@test (try take!(ch) catch e; e; end) isa StackOverflowError
end

0 comments on commit 8af2576

Please sign in to comment.