[BoF] error after deleting var ctx part of dyn sym

Q&A's, tips, howto's

[BoF] error after deleting var ctx part of dyn sym

Postby hartrock » Sun Dec 20, 2015 3:52 am

While looking deeper into the semantics of dynamic symbols, there has been this unexpected behavior:
Code: Select all
sr@freen:~/newLISP$ newlisp
newLISP v.10.6.5 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

>
(set 'sy nil)
(define (f) (println 'sy:bar))
(delete 'sy)
(f)

nil
(lambda () (println 'sy:bar))
true
�~�:bar
bar:bar
>
hartrock
 
Posts: 136
Joined: Wed Aug 07, 2013 9:37 pm

Re: [BoF] error after deleting var ctx part of dyn sym

Postby Lutz » Sun Dec 20, 2015 7:10 pm

When a deleted symbol was prefix in a dynamic symbol, memory got corrupted. The dynamic symbol reference is now replaced with nil like other symbol references:

http://www.newlisp.org/downloads/develo ... nprogress/
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: [BoF] error after deleting var ctx part of dyn sym

Postby hartrock » Sun Dec 20, 2015 11:02 pm

Thanks, Lutz!

By your fix a 'Bus error' related to this problem has disappeared, too (in a more complex scenario: had just given a minimal version to trigger the problem).
hartrock
 
Posts: 136
Joined: Wed Aug 07, 2013 9:37 pm

Re: [BoF] error after deleting var ctx part of dyn sym

Postby hartrock » Sun Dec 20, 2015 11:45 pm

[Update with full example]
Unfortunately I have to put some water into the wine...
Code: Select all
newLISP v.10.6.5 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

>
(set 'sy nil)
(set 'foo MAIN)
(define (f) (foo:println 'sy:bar))
(delete 'sy)
f

nil
MAIN
(lambda () (foo:println 'sy:bar))
true
(lambda () (nil 'nil))
>

Fix is nil'ing too much...
hartrock
 
Posts: 136
Joined: Wed Aug 07, 2013 9:37 pm

Re: [BoF] error after deleting var ctx part of dyn sym

Postby TedWalther » Mon Dec 21, 2015 4:34 am

I sometimes wish "referring" to a unknown symbol wasn't the same thing as "defining" it. perhaps if all symbols were stuck into the "undefined" context until they were properly defined by "set" or "define". Perhaps instead of "global" being a property of a symbol, global symbols would be moved to the GLOBAL context...
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.
TedWalther
 
Posts: 605
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: [BoF] error after deleting var ctx part of dyn sym

Postby Lutz » Mon Dec 21, 2015 3:17 pm

Corrected: http://www.newlisp.org/downloads/develo ... nprogress/

To Ted:
Requirement to define / declare variables also makes programming less casual and less interactive. Perl has a strict mode to turn it on and of. But not sure if its worth the additional code. One of the things people like about newLISP is, that it is fully dynamic.
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: [BoF] error after deleting var ctx part of dyn sym

Postby TedWalther » Mon Dec 21, 2015 10:34 pm

Yes, I like the fully dynamic nature of newLisp. But, this summer, I ran into a lot of problems in coding with a team, because it was a big mystery where things were being defined. And using symbols that were expected to be defined but weren't, caused big headaches. The bug could cascade and cause errors far down the line. Not sure what is the right solution to that, but a "strict" mode for debugging would be nice.

I was thinking about debugging in another way: line numbers. If tokens were tagged with a line number when read from source, and also inherit line numbers from whatever altered them, that might make debugging easier. I'm not sure, did LISP ever have compilers that locate errors on a line? Is there some other debugging idiom? Being able to dump the state machine with a pointer showing where the error was in that code, would also be helpful. By state machine, I mean the output of (save). Sort of like the way SmallTalk snapshots the VM.

Now, for speed, I'm sure both of these suggestions are terrible. But for debugging, I think they would be useful. Be nice to have a parallel version of newlisp for this type of stuff.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.
TedWalther
 
Posts: 605
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: [BoF] error after deleting var ctx part of dyn sym

Postby abaddon1234 » Wed Jun 08, 2016 12:28 am

Thanks for the info
สล็อต
abaddon1234
 
Posts: 21
Joined: Mon Sep 14, 2015 3:09 am


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests