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

segfault on IO.print(new List) #25

Closed
kmarekspartz opened this issue Feb 16, 2014 · 6 comments
Closed

segfault on IO.print(new List) #25

kmarekspartz opened this issue Feb 16, 2014 · 6 comments

Comments

@kmarekspartz
Copy link
Contributor

> IO.print(new List)
zsh: segmentation fault  ./wren
@kmarekspartz
Copy link
Contributor Author

Or:

> var x = new List
> x.add(1)
wren(90830,0x7fff7748b310) malloc: *** error for object 0x2: pointer being realloc'd was not allocated
*** set a breakpoint in malloc_error_break to debug
zsh: abort      ./wren

@munificent
Copy link
Member

Ah good catch. You can probably cause the same problem by calling new on any of the built-in classes: Bool, Num, Fiber, Function, etc.

The problem is that instances of those types are special in the VM. Calling new creates the wrong type and then methods on that object go haywire.

It would be nice if new List and new Fiber could be made to do something useful, but that will be tricky with the sematics of how new is compiled. The simplest fix is probably just to make those classes implement new methods that raise runtime errors.

@tamc
Copy link
Contributor

tamc commented Jan 4, 2015

Can't replicate this as of 84ead3b on OSX Yosemite

> IO.print(new List)
[]
> var x = new List
> x.add(1)
>

Is it fixed?

@kmarekspartz
Copy link
Contributor Author

I'll try this out today.

@kmarekspartz
Copy link
Contributor Author

It works for me now.

@munificent
Copy link
Member

\o/

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