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

Possible dispatch error leading to Julia freezing #7534

Closed
mlhetland opened this issue Jul 7, 2014 · 2 comments
Closed

Possible dispatch error leading to Julia freezing #7534

mlhetland opened this issue Jul 7, 2014 · 2 comments
Assignees
Labels
needs tests Unit tests are required for this change types and dispatch Types, subtyping and method dispatch

Comments

@mlhetland
Copy link
Contributor

I've come across what seems to me to be a bug in Julia, related to dispatch, I guess. I've reduce the problem to a couple of simple examples; one is given below, and another (with more undefined variables etc. that go undetected) can be found in the discussion at Julia-Users. In my original code, the problem is that the dispatch seems to go to the wrong function, creating infinite mutual recursion. In the simplified code below, I've removed the alternative function (and other scaffolding code), so the expected behavior would be a method error, I guess?

type B
end

type X{T}
    baz::Vector{T}
end

function foo(a, c)
    bar(b, c)
end

function bar{T}(d::(X{T}, Int), val::T)
    foo("err", d[1].baz)
end

b = B()

function test()
    bar(b, "wat")
end

test()

When I run this, I would have expected:

ERROR: no method bar(B, ASCIIString)

Instead, the code just hangs. I'm not sure if it's really looping between foo and bar—I haven't been able to produce any evidence of that, really. Printing (with flushing) doesn't work, and undefined variables are ignored (c.f., the longer example on Julia-Users). Could it be some loop/mutual recursion going on in Julia itself (in the inference/dispatch)?

Here's my versioninfo():

Julia Version 0.3.0-prerelease+3884
Commit 3e6a6c7* (2014-06-25 10:41 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin12.5.0)
  CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  WORD_SIZE: 64
  BLAS: libgfortblas
  LAPACK: liblapack
  LIBM: libopenlibm
@simonster simonster added the bug label Jul 7, 2014
@JeffBezanson JeffBezanson self-assigned this Jul 27, 2014
@ihnorton ihnorton added the types and dispatch Types, subtyping and method dispatch label Feb 1, 2015
@jmert
Copy link
Contributor

jmert commented Mar 19, 2015

I think I might have found the same issue through a different means. I've attached the minimum working example I've been able to hobble together, a snippet of logs that my kernel spits out, and an strace of the process right before I enter the last line of the MWE through the hung point.

The process hangs to the point that I've only been able to kill the process by rebooting my computer entirely. Trying to get the PID through ps ends up hanging itself, and when I take the PID before hanging julia, I also can't kill -9 the process successfully.

strace: http://pastebin.com/iSJ75P1V
kernel messages: http://pastebin.com/8tUVJdMp
MWE: http://pastebin.com/FZLsUk3A

@ihnorton
Copy link
Member

ihnorton commented Mar 6, 2016

Original test case is fixed on latest master. jmert's case stackoverflows, but line 29 doesn't really make sense.

needs-test before closing?

@ihnorton ihnorton added needs tests Unit tests are required for this change and removed bug Indicates an unexpected problem or unintended behavior labels Mar 6, 2016
@vtjnash vtjnash closed this as completed Mar 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs tests Unit tests are required for this change types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

6 participants