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 after printing results #360

Open
developedby opened this issue May 29, 2024 · 2 comments
Open

Segfault after printing results #360

developedby opened this issue May 29, 2024 · 2 comments

Comments

@developedby
Copy link
Member

Reproducing the behavior

Running this program with hvm run-c causes a segmentation fault after printing the results

@List/Cons = (a (b ((@List/Cons/tag (a (b c))) c)))

@List/Cons/tag = 1

@List/Nil = ((@List/Nil/tag a) a)

@List/Nil/tag = 0

@List/append = ((@List/append__C3 a) a)

@List/append__C0 = (* (c (d (a (b (* g))))))
  & @List/Cons ~ (a (f g))
  & @List/append ~ (b (e f))
  & @List/Cons ~ (c (d e))

@List/append__C1 = (?(((* (* (a a))) @List/append__C0) b) b)

@List/append__C2 = (* ({a c} ({b d} ((@List/append__C1 (a (b (e f)))) f))))
  & @List/Cons ~ (c (d e))

@List/append__C3 = (?(((a a) @List/append__C2) b) b)

@gen_lst = a
  & @gen_lst__bend0 ~ a

@gen_lst__bend0 = (a ({$([<0] ?(((* (* @List/Nil)) @gen_lst__bend0__C0) (a (b c)))) b} c))

@gen_lst__bend0__C0 = (* ($([%] $(a $([*7] $([+3] {b $([:%5] $([+3] c))})))) ({$([:-1] d) a} f)))
  & @List/Cons ~ (b (e f))
  & @gen_lst__bend0 ~ (c (d e))

@main = (* a)
  & @main2 ~ (32 a)

@main2 = (a (b d))
  & @gen_lst ~ (31 (a {b c}))
  & @quickSort ~ (c d)

@partition = a
  & @partition__fold0 ~ a

@partition__fold0 = ((@partition__fold0__C3 a) a)

@partition__fold0__C0 = (b (a (c (a d))))
  & @List/Cons ~ (b (c d))

@partition__fold0__C1 = (* (a (b (d (c d)))))
  & @List/Cons ~ (a (b c))

@partition__fold0__C2 = (* ({c d} (a ({b $([>] $(c ?((@partition__fold0__C0 @partition__fold0__C1) (d (e (f g))))))} g))))
  & @partition__fold0 ~ (a (b (e f)))

@partition__fold0__C3 = (?(((* (@List/Nil @List/Nil)) @partition__fold0__C2) a) a)

@quickSort = ((@quickSort__C1 a) a)

@quickSort__C0 = (* ({b e} (a i)))
  & @List/append ~ (d (h i))
  & @partition ~ (a (b (c f)))
  &!@quickSort ~ (c d)
  & @List/Cons ~ (e (g h))
  &!@quickSort ~ (f g)

@quickSort__C1 = (?((@List/Nil @quickSort__C0) a) a)

If we change the number on @main to be smaller than 32 this doesn't happen

System Settings

  • OS: Linux (OpenSuse Tumbleweed)
  • CPU: AMD Ryzen 7 5800H

Additional context

No response

@edusporto
Copy link
Contributor

Minimum reproduction of the same bug in Bend:

def create(n):
  bend x = 0:
    when x < n:
      str = List/Cons { head: 1, tail: fork(x + 1) }
    else:
      str = List/Nil
  return str

def main():
  return create(37)

This is due to the fixed-size stack variable in the pretty_print_port function here.

Increasing the size of this array postpones the problem - although it increases the maximum size of the created list before segfaulting, it doesn't really solve the problem. I'm working on direct net readback through interop in Rust - that would fix the problem until the readback function in Rust overflows 😛

For now I think we could increase this array, since 256 really is quite short

@enricozb
Copy link
Contributor

Just commenting here so I can refer back to it, this pretty_print_port will break even further with my planned extended numerics changes (will be using ERA as a pointer), so I'll fix this then.

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