newLISP Fan Club

Forum => newLISP and the O.S. => Topic started by: alex on August 04, 2011, 09:55:37 AM

Title: Exploit?
Post by: alex on August 04, 2011, 09:55:37 AM
(define (test) (test1))
(define (my-error-handler)    
      (println "error # " (error-text (error-number)) " has occurredn"))
(error-event 'my-error-handler)
(test)

OS = Windows7 x64

newlisp = v.10.3.2



newlisp window closed without messages, but I have Windows messge about error.
Title: Re: Exploit?
Post by: Lutz on August 04, 2011, 12:04:15 PM
'error-number' and 'error-text' were replaced with 'last-error' in version 10.1.0, released in June 2009.



Try the following code:


(define (test) (test1))
(define (my-error-handler)    
      (println (last-error)))
(error-event 'my-error-handler)
(test)


See also here: http://www.newlisp.org/downloads/newlisp_manual.html#last-error

and here: http://www.newlisp.org/downloads/newlisp_manual.html#error-event
Title: Re: Exploit?
Post by: alex on August 06, 2011, 12:21:58 PM
I knew about 'error-number' and 'error-text', but why such "dramatical" :-) exit without newlisp error and with Windows error?

More  precise variant, with the same exit:
(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)

Has Linux the same problem?
Title: Re: Exploit?
Post by: Lutz on August 06, 2011, 06:55:31 PM
In your last example:


(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)


... the error handler itself produces an error and calls itself, causing an infinite loop, because 'test2' is not defined.



The following example:
(define (my-error-handler)    
      (println (last (last-error))  " must exit")
      (exit))

(error-event 'my-error-handler)
(test)

... runs well on all platforms:
~> newlisp test
ERR: invalid function : (test) must exit
~> cat test
Title: Re: Exploit?
Post by: Lutz on August 06, 2011, 06:56:22 PM
In your last example:


(define (my-error-handler) (test2))
(error-event 'my-error-handler)
(test)

... the error handler itself produces an error and calls itself in an infinite loop, because 'test2' is not defined.



The following example:
(define (my-error-handler)    
      (println (last (last-error))  " must exit")
      (exit))

(error-event 'my-error-handler)
(test)

... runs well on all platforms:
~> newlisp test
ERR: invalid function : (test) must exit
~>
Title: Re: Exploit?
Post by: alex on August 10, 2011, 09:44:53 AM
I understand my mistake. Thanks you, Lutz.