ucblogo-code icon indicating copy to clipboard operation
ucblogo-code copied to clipboard

Segmentation fault on invoking oddly defined procedure.

Open zigggit opened this issue 4 years ago • 1 comments

If a procedure similar to the following is defined

to stuff [ 1 ] print [Any Logo you like here] end

then UCB Logo exits with a segmentation fault as soon as the procedure is invoked.

Is this even a valid thing to define? My knowledge isn't good enough to be certain, but I suspect it might not be. Perhaps such a definition should be rejected in the first place.

zigggit avatar May 05 '20 11:05 zigggit

Indeed, that's not a well-formed TO form. It should error rather than segfaulting, of course.

My guess is that TO is treating the [1] as if it were [:foo], i.e., using 1 as the variable name for a rest argument. So when STUFF is invoked, it's trying to set the value of 1 to a list of inputs (in this case an empty list, but if it were (STUFF A B C) the list would be [A B C].

You can have a variable named 1, by saying MAKE 1 [some value]. Then ? print 1 1 ? print :1 some value

brianharvey avatar May 05 '20 11:05 brianharvey