Page 1 of 1

segmentation faults on net-select

Posted: Sat Apr 16, 2005 12:11 pm
by newdep
Hi Lutz,

newlisp linux 8.5.3 (or since 8.5.0)

Im not quiet sure yet but i think its related to an empty list!

when net-select does anything on an empty variable/list im
getting sometimes a segmentation fault... like ->

(setq the-list '())
(until (net-error)
...
(dolist (x (net-select the-list "r" 1000))
(something))
)


Norman.

Posted: Sat Apr 16, 2005 12:33 pm
by Lutz
In 8.5.0 and previous versions (back to 8.3.2) it was not safe to change the list 'dolist' was iterating through and one would use a copy for iterating. In 8.5.3 this is safe. Can you find out exactly which version works and not works and send me an example (as small as possible) ?

Lutz

Posted: Fri Apr 22, 2005 10:52 pm
by newdep
Hi Lutz,

Well actualy the example is quit simple , see below.
It looks like 'select on empty lists simply goes wrong.
It already fails during the start of the script

I tested it back to 8.2.6 but they all do a segmentation fault..

(setq clients '())
(setq connection (net-listen 54054 "127.0.0.1"))

(until icecream-is-melting

(if (net-select connection "r" 1000)
(setq id (net-accept connection))
(push clients id ))

(dolist (client (net-select clients "r" 1000)) )
(dolist (client (net-select clients "w" 1000)) )
)


---> if I do this... then it works -->
(if (not (empty? clients)) (dolist (client (net-select clients "r" 1000)) ))
(if (not (empty? clients)) (dolist (client (net-select clients "w" 1000)) ))


Norman.

Posted: Fri Apr 22, 2005 11:46 pm
by Lutz
This is fixed in version 8.5.4:

http://newlisp.org/downloads/development/

Lutz