brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 110 forks source link

Unsafe calls in runtime need to be wrapped with safeCall #1251

Open rachitnigam opened 6 years ago

rachitnigam commented 6 years ago

While working on Stopify, I found some calls in the runtime that try to capture the stack but are in a context that can't capture the stack leading to either code being skipped or runtime errors. I'll add them as comments. For each call, we have to either wrap it in a safeCall or make sure we never call a function that tries to capture.

jpolitz commented 6 years ago

Will there be a way to reference those comments from this issue?

rachitnigam commented 6 years ago

https://github.com/brownplt/pyret-lang/blob/75f1fca9e4de3be1a582462bd4a112cda73783ee/src/js/base/runtime.js#L5233

Annotations might have abitrary non-flat functions.

rachitnigam commented 6 years ago

@jpolitz yeah, I'm adding the comments here.

rachitnigam commented 6 years ago

PostloadHooks can also capture: https://github.com/brownplt/pyret-lang/blob/75f1fca9e4de3be1a582462bd4a112cda73783ee/src/js/base/handalone.js#L88

rachitnigam commented 6 years ago

Not sure why this one happens: https://github.com/brownplt/pyret-lang/blob/75f1fca9e4de3be1a582462bd4a112cda73783ee/src/js/base/handalone.js#L160

rachitnigam commented 6 years ago

@jpolitz mentioned to me that a student in Shriram's class also found the non-flat annotation bug. As note to whoever is trying to fix it on master: adding a safeCall here: https://github.com/brownplt/pyret-lang/blob/75f1fca9e4de3be1a582462bd4a112cda73783ee/src/js/base/runtime.js#L5233

will also force you to put a safeCall here: https://github.com/brownplt/pyret-lang/blob/75f1fca9e4de3be1a582462bd4a112cda73783ee/src/js/base/runtime.js#L5296

doing so will break other things because funToReturn (the function containing call to makeConstructor) is often called from contexts that can't capture the stack (I think there is particular one that fails from makeFailureResult).

I don't have a complete solution right now since for the stopify branch, I just disable capturing when calling makeConstructor.