Mark H Weaver <m...@netris.org> skribis: > Hi Ludovic, > >> The problem here is that, when the second overflow occurs, that reserve >> has already been used, so it just aborts. >> >> Commit 70057f3 in ‘stable-2.0’ fixes that (will be in 2.0.10.) > > Thanks for fixing this, but there's still a slight problem. After a VM > overflow is caught and the user is left in the debugger, typing ",q" > sometimes causes another stack overflow. > > To reproduce this problem, type the exact commands shown in > <http://bugs.gnu.org/15065>. Using v2.0.9-118-g70057f3 on either x86_64 > or mips64el (with N32 ABI), this is what I see: > > [...] > scheme@(guile-user)> (integral cube 0.0 1.0 0.01) > $1 = 0.24998750000000042 > scheme@(guile-user)> (integral cube 0.0 1.0 0.001) > $2 = 0.249999875000001 > scheme@(guile-user)> (integral cube 0.0 1.0 0.0001) > <unnamed port>:7:11: In procedure sum: > <unnamed port>:7:11: Throw to key `vm-error' with args `(vm-run "VM: Stack > overflow" ())'. > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> ,q > ice-9/boot-9.scm:65:2: In procedure abort-to-prompt: > ice-9/boot-9.scm:65:2: Throw to key `vm-error' with args `(vm-run "VM: Stack > overflow" ())'. > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> ,q > scheme@(guile-user)>
The second overflow occurs because the stack reserve is reinstated before the handler is invoked, so the handler doesn’t have enough stack space to run: --8<---------------cut here---------------start------------->8--- scheme@(guile-user) [1]> ,q ice-9/boot-9.scm:65:2: In procedure abort-to-prompt: ice-9/boot-9.scm:65:2: Throw to key `vm-error' with args `(vm-run "VM: Stack overflow" ())'. Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile-user) [1]> ,bt In ice-9/boot-9.scm: 157:177216 (catch quit #<procedure 16adcf0 at system/repl/repl.scm:181:18 ()> #<procedure ff4220 at system/repl/repl.scm:200…> …) In system/repl/repl.scm: 191:317215 (#<procedure 16adcf0 at system/repl/repl.scm:181:18 ()>) In ice-9/boot-9.scm: 157:177214 (catch #t #<procedure 16bd0c0 at system/repl/error-handling.scm:96:6 ()> #<procedure 1105e20 at system/repl/error…> …) In system/vm/trap-state.scm: 172:47213 (with-default-trap-handler #<procedure debug-trap-handler (frame trap-idx trap-name)> #<procedure 1105d60 at syst…> …) In ice-9/boot-9.scm: 1650:47212 (%start-stack #t #<procedure 16bd120 at system/repl/repl.scm:192:32 ()>) 1655:97211 (#<procedure 16bd030 ()>) In system/repl/repl.scm: 148:47210 (with-stack-and-prompt #<procedure 1105e40>) In ice-9/boot-9.scm: 1650:47209 (%start-stack #t #<procedure 1105b20 at system/repl/repl.scm:149:33 ()>) 1655:97208 (#<procedure 16bd000 ()>) In current input: 2:40957207 (integral #<procedure cube (x)> 0.0 1.0 1.0e-4) --8<---------------cut here---------------end--------------->8--- I tried using a making the ‘quit’ handler in repl.scm a pre-unwind handler but that doesn’t help. Ideas? Ludo’.