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 @ 24.5.3 in REPL #1095

Open
felix-alonso opened this issue Nov 13, 2022 · 0 comments
Open

SegFault @ 24.5.3 in REPL #1095

felix-alonso opened this issue Nov 13, 2022 · 0 comments

Comments

@felix-alonso
Copy link

Section 24.5.3 has to do with printing stack traces. It ends with entering in a broken program to demonstrate the stack trace.

fun a() { b(); }
fun b() { c(); }
fun c() {
  c("too", "many");
}

a();

If you run the program from the REPL by creating each definition in turn then at this point in the chapter you will produce a segfault after you enter in the second function. (Really it works with any pair of statements you enter.) This is fixed in the next section (24.5.4) because we add in return values so all's well that ends well.

However, I would recommend adding a note next to the example that warns the user that they will get a SegFault from the REPL, but not from a file. (It could even include a cheeky author comment asking the reader to consider why this might be the case.)

I burned an hour trying to figure out why the vm.frameCount underflowed (That's C, baby!) and where I deviated from the book as written. Turns out everything was working as expected. I just needed to keep following the book.


Thanks for writing this lovely book and putting it online! Really appreciate it!

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

1 participant