Subject: A bug that made the server infinite loop

From: Moonchilde <[email-masked]>
Date: Sat, 1 Aug 1992 19:08:17 -0700

While playing with the core db code I came upon something interestiing.
It involves the seq_utils code as distributed in the LambdaCore db.
Here is what I did to get it to go boom.

;$seq_utils:complement($seq_utils:from_sorted_list({1,3,5,6,7,8,10,11}))
=>  {-2147483648, 1, 2, 3, 4, 5, 9, 10, 12}
;$seq_utils:size({-2147483648, 1, 2, 3, 4, 5, 9, 10, 12})
=>  -8
;$seq_utils:tolist({-2147483648, 1, 2, 3, 4, 5, 9, 10, 12})
-----> infinite loop.
(here's the PS aux output from the machine I'm running on.  Ignore the memory
sizes, MACH's memory tracking on process size is broken)
jtraub   16490  70.2  7.235.4M2.30M p4 RW   12:51 ./moo MoonMOO.db MoonMOO.db.n
--------
>From an initial run through the debugger, it looks like the code is trying
to grow a list to infinite size.  Unfortunately, I haven't looked through the
code enough to track it down more precisely.. I will try to do so.

-------
Here is the code for $seq_utils:tolist (just in case it's different)
-------------------------------------------
seq = args[1];
if (!seq)
  return {};
else
  if (length(seq) % 2)
    seq = {@seq, this.maxneg};
  endif
  l = {};
  for i in [1..length(seq) / 2]
    for j in [seq[2 * i - 1]..seq[2 * i] - 1]
      l = {@l, j};
    endfor
  endfor
  return l;
endif

--Moonchilde