« first day (3305 days earlier)      last day (475 days later) » 

6:13 AM
0
Q: What (if any) JavaScript operations are guaranteed not to cause stackoverflow RangeErrors?

HostileForkIn C programming, stack overflow errors are outside of the language spec. They represent a fundamental violation of the "contract" of what a function call means. You can overflow the stack halfway through pushing arguments to a function. Or you can overflow it mid-way through a library routine...

 
 
6 hours later…
 
3 hours later…
3:05 PM
Getting back to Rebol this week. Somewhat further along on getting some answers on how we might safely handle stack overflows. As I've pointed out that you shouldn't believe the hype and JavaScript cannot safely recover either, it's hard to expect us to be able to when running under a browser.
2
 
3:38 PM
My likely verdict is that it's time to scrap the non-standard means of guessing at the stack limit. It isn't working in Wasm. We can attack it with heuristics; maybe the first time you run Rebol in a browser it does a dummy test to feel out your browser's stack limits and stores that in a cookie or something. If you get a stack overflow crash it pops up a slider(s) to adjust the heuristics for next time so it will pre-empt the crash more effectively.
To do that calibration when you're not inside a browser you would have to use CALL to spawn another instance and pipe back a feed of status pings ("At recursion 4080, I'm still ok! => At recursion 4081, I'm still ok!" => ...silence, because it crashed...) That's because C just crashes on stack overflows. Then use whatever the limit you found as feedback to the heuristic.
Unfortunately you couldn't give people a message about tuning the heuristic on an actual stack overflow crash in ordinary C as a desktop/console program--you don't have the opportunity. You could write some status file on startup and delete it on clean shutdown, and then the next startup could remark about what you might do about the crash if it saw the file still there.
To do this right requires a real culture change in software engineering regarding quality-of-service at the hardware/OS level. It means embracing Real-Time OS concepts and connecting the knowledge of various layers to give contractual guarantees that are systemically enforceable. I've wanted to see that since college but it has only been getting worse--it's naive to expect change.
 
 
4 hours later…
8:06 PM
@HostileFork Does it differ for the same browser on different machines?
 
8:16 PM
@GrahamChiu Yes. Really the only way to deal with this "safely" would be to mimic the methods of something like Stackless Python: "It avoids depending on the C call stack for its own stack. In practice, Stackless Python uses the C stack, but the stack is cleared between function calls."
 
8:48 PM
We actually may be rather close to being able to do something along these lines, at least with natives that use the "internal" API. It is probably worth looking at. That would cut down on stack overflow errors (and so do other techniques, like usermode tail calls, which we support with REDO). But knowing you are in a safe and stable situation to resume if and when one happens is not addressed by this.
 
9:36 PM
This is a tough balance: On the one hand, you can't be all things to all people. The project goal is not "fundamentally harden the substrate on which software is written". On the other hand: when you have superficially-similar peer implementations like CPython which people have moved on from, one hates to be making naive mistakes.
@hostile I see what you are saying now. I agree. If the stack hits heap, and you can't know what function might be active and what it is doing, that's fatal. — Johannes Schaub - litb 1 min ago
There seems to be a lot of misinformation about stack overflow errors by people who I do not think have really thought this through. I had intended to write a blog article about it when I was first poking around and gathering some information, and it seems like this is an article that really needs to be written.
 

« first day (3305 days earlier)      last day (475 days later) »