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

Misnamed struct field in inspect/2 causes infinite loop #2503

Closed
jdeisenberg opened this issue Jul 8, 2014 · 0 comments
Closed

Misnamed struct field in inspect/2 causes infinite loop #2503

jdeisenberg opened this issue Jul 8, 2014 · 0 comments
Milestone

Comments

@jdeisenberg
Copy link
Contributor

Using Erlang/OTP 17, Interactive Elixir (0.14.3-dev)

Consider this code, with an error: colour in the structure is misspelled as color in inspect/2

defmodule Shirt do
  defstruct size: "M", colour: "green"
end

defimpl Inspect, for: Shirt do
  import Inspect.Algebra
  def inspect(item, _options) do
    msg = concat([item.size, break, item.color])
    pretty(msg, 80)
  end
end

Now do this:

iex(1)> c "shirt.ex"
[Inspect.Shirt, Shirt]
iex(2)> %Shirt{}

Crash dump was written to: erl_crash.dump
eheap_alloc: Cannot allocate 1098556536 bytes of memory (of type "heap").

If you put an IO.puts("testing") into the inspect/2 function, you will see that this is an infinite loop.

@josevalim josevalim added this to the v1.0 milestone Jul 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants