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

segmentation fault in recursive Task #1485

Closed
zubchick opened this issue Nov 1, 2012 · 2 comments
Closed

segmentation fault in recursive Task #1485

zubchick opened this issue Nov 1, 2012 · 2 comments

Comments

@zubchick
Copy link

zubchick commented Nov 1, 2012

Hi, I tried to reproduce python code in julia

In [1]: def f():
   ...:     yield f()

In [2]: next(f())
Out[2]: <generator object f at 0x1427640>

In [3]: next(next(f()))
Out[3]: <generator object f at 0x1427730>

I'm not really sure that i wrote it right:

julia> function test()
       produce(test())
       end

julia> t = Task(test)
Task

julia> consume(t)

And got this:

julia(90886,0x7fff73df5960) malloc: *** mmap(size=140730481774592) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
julia(90886,0x7fff73df5960) malloc: *** mmap(size=140730481782784) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
julia(90886,0x7fff73df5960) malloc: *** mmap(size=140730481790976) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
^C^C^C
[1]    90886 segmentation fault  ./julia

Version 0.0.0+100556114.r27bb

@toivoh
Copy link
Contributor

toivoh commented Nov 1, 2012

In python, any function that uses yield automatically returns a generator.
In julia, you always have to wrap the function into a Task manually, so your code should be

function test()
    produce(Task(test))
end

which works for me.

The function

function test()
    produce(test())
end

evaluates itself in an infinite recursion trying to produce a value to give to produce, so it should give a stack overflow error, and it does if I call it as test(). I can confirm that your code gives a segfault for me too, so yes, this must be a bug.

@JeffBezanson
Copy link
Member

The stack overflow is certainly the origin of the problem.

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

3 participants