[squeak-dev] RawBitsArray vs. DataStream
David T. Lewis
lewis at mail.msen.com
Wed Nov 23 02:54:47 UTC 2022
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;
> 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
The fix would be to put the private methods into a method category
More information about the Squeak-dev