Skip to content

Uncaught exceptions from tasks #32034

Closed
Closed

Description

If a task throws an exception it goes down silently. This issue was reported before (#12485) and seemed to be fixed in version 1.1 (#28878), but it popped up (or it didn't) in one of my unit tests. A similar scenario:

broken example

c = Channel{Int}(2)

@async begin
  for i in 1:2
    for j in 1:2
      put!(c, i+j)
    end
    close(c)
  end
end

@sync for _ in 1:Sys.CPU_THREADS
  @async for x in c 
    println(x)
  end
end

Output:

2
3

corrected example

c = Channel{Int}(2)

@async begin
  for i in 1:2
    for j in 1:2
      put!(c, i+j)
    end
  end
  close(c) # only line that changed
end

@sync for _ in 1:Sys.CPU_THREADS
  @async for x in c 
    println(x)
  end
end

Output:

2
3
3
4

versioninfo

Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions