Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: fix potential bug in 'print path' tracking (gap-system#5862)
The kernel function `SetPrintObjState` is used to save the current printing state at the start of a new read-eval-loop, and to restore it to the previous value. The idea here being that if an error triggering a break loop is raised in the middle of printing, the printing state is stored; then the user performs action in the break loop, which of course can trigger printing, and thus modify the kernel printing state. Hence it makes sense to save and restore this state. Alas, we only stored the current depth of the printing stack, but not its *content*. Any printing in the print loop would overwrite this content. So in the above scenario, after existing the break loop, we'd be accessing the wrong objects. In fact these objects might not even exist anymore, and a crash could result. We solve this by adjusting the code modifying these stacks to actually safe and restore the content of the printing stacks, too. Most likely nobody ever triggered this.
- Loading branch information