[squeak-dev] RawBitsArray vs. DataStream

Marcel Taeumel marcel.taeumel at hpi.de
Wed Nov 23 10:13:09 UTC 2022

Aha! Thanks for the clarification! :-)

Am 23.11.2022 03:54:55 schrieb David T. Lewis <lewis at mail.msen.com>:
On Tue, Nov 22, 2022 at 10:58:09AM +0100, Marcel Taeumel wrote:
> Hi all --
> Should the following work?

No, it should not work. And yes, it will lock up the image (confirmed
on Linux 64-bit).

> class := DoubleByteArray.
> size := 10.
> dummy := 123.
> array := class new: size.
> array?? atAllPut: dummy.
> (DataStream newFileNamed: 'numbers')
> nextPut: array;
> close.
> stream := DataStream fileNamed: 'numbers'.??
> load := stream readArray.
> stream close.
> load explore

DataStream>>readArray is a private method that will do bad things
if you call it at the wrong time. In the example above, it reads
a number from the wrong place in the stream (because it should not
have been called at that point). This number is used to allocate
an array with over 150 million 8-byte slots, leading to the apparent
image lockup.

The fix would be to put the private methods into a method category
labeled "private".


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221123/17838192/attachment.html>

More information about the Squeak-dev mailing list