home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 116,250 of 117,927   
   Krishna Myneni to Krishna Myneni   
   Re: push for memory safe languages -- im   
   02 Mar 24 10:17:57   
   
   From: krishna.myneni@ccreweb.org   
      
   On 3/2/24 10:08, Krishna Myneni wrote:   
   > On 3/2/24 09:39, minforth wrote:   
   >> Harden these without runtime checks:   
   >> : RT1 2 3e recurse ;   
   >> : RT2 drop fdrop recurse ;   
   >   
   > Let's see what python does:   
   >   
   > def rt1():   
   >     return rt1()   
   >   
   > rt1()   
   > Traceback (most recent call last):   
   >    File "", line 1, in    
   >    File "", line 2, in rt1   
   >    File "", line 2, in rt1   
   >    File "", line 2, in rt1   
   >    [Previous line repeated 996 more times]   
   > RecursionError: maximum recursion depth exceeded   
   >   
   > Clearly it is doing a runtime check. Similarly one could have RECURSE in   
   > Forth perform a runtime check to enforce a recursion depth limit, and   
   > indeed this type of error is caught by several Forth systems:   
   >   
   > === kForth example ===   
   > : rt1 recurse ;   
   >   ok   
   > rt1   
   > Line 2:  VM Error(-258): Return stack corrupt   
   > rt1   
   > === end example ===   
   >   
   > === Gforth example ===   
   > : rt1 recurse ;  ok   
   > rt1   
   > *the terminal*:2:1: error: Return stack overflow   
   >  >>>rt1<<<   
   > === end example ===   
   >   
      
   To be clear, if you try to fill up the fp or data stack, as with your   
   rt1 example, kForth does give a segfault (and hence is susceptible to an   
   exploit), while Gforth still gives the same error.   
      
   --   
   Krishna   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca