Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!star.cs.vu.nl!jos@cs.vu.nl From: jos@cs.vu.nl (Jos Warmer) Newsgroups: comp.lang.eiffel Subject: Bug in array.resize Message-ID: <5984@star.cs.vu.nl> Date: 15 Mar 90 09:17:40 GMT Sender: news@cs.vu.nl Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 51 The resize routine is incorrect for zero sized arrays: class FORCE feature s : ARRAY[STRING]; Create is do s.Create(1, 0); s.force("twelve", 12); end; end; Ruinning gives: System execution failed. Below is the sequence of recorded exceptions: -------------------------------------------------------------------------------- Object Class Routine Nature of exception Effect -------------------------------------------------------------------------------- 6C540 ARRAY resize External event: Segmentation fault. Fail -------------------------------------------------------------------------------- 6C540 ARRAY force External event: Segmentation fault. Fail -------------------------------------------------------------------------------- 6CAFC FORCE create External event: Segmentation fault. Fail -------------------------------------------------------------------------------- The problem is identified as follows: In array.resize the C function `arycpy' is called. This function is defined in the file `_basic.c'. It calls the macro `gentest' with first argument `oldarea' (which is the `area' from class array). This macro tries to get the `info' field of area. Beacuse the array is empty, area was never assigned to, so this means dereferencing a null pointer. Ergo: segmentation fault. Jos Warmer jos@cs.vu.nl PS: I sometimes get the same execution failure with non-zerosized arrays. But I cannot reproduce them in a small example. -- Jos Warmer jos@cs.vu.nl ...uunet!mcvax!cs.vu.nl!jos