Hi all --
Should the following work?
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
Best, Marcel
Hi Marcel, I would expect that a RawBitsArray just store the raw bits on the dataStream... I would not expect that a low level layer would interpret the contents of raw bits!
Le mar. 22 nov. 2022 à 10:58, Marcel Taeumel marcel.taeumel@hpi.de a écrit :
Hi all --
Should the following work?
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
Best, Marcel
Hi Marcel,
On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi all --
Should the following work?
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
Write a test :-)
testRawBits ((RawBitsArray subclasses reject: #isAbstract), ((RawBitsArray subclasses select: #isAbstract) collect: #subclasses)) flatten do: [:class| | instance | instance := class new: 10. instance first isColor ifTrue: [1 to: instance size do: [:i| instance at: i put: (Color r: i * 1 g: i * 2 b: i * 3)]] ifFalse: [1 to: instance size do: [:i| instance at: i put: i]]. self assert: instance equals: (self testObject: instance) description: 'A ', class name, ' should be serializable']
see Tests-eem.494
Best, Marcel
Hi Eliot --
Write a test :-)
My image freezes. It seems totally broken. That's why I asked. I wanted to learn more about the expected behavior. After that, I could write a test. ;-)
Best, Marcel Am 22.11.2022 13:50:30 schrieb Eliot Miranda eliot.miranda@gmail.com: Hi Marcel,
On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel <marcel.taeumel@hpi.de [mailto:marcel.taeumel@hpi.de]> wrote:
Hi all --
Should the following work?
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
Write a test :-)
testRawBits ((RawBitsArray subclasses reject: #isAbstract), ((RawBitsArray subclasses select: #isAbstract) collect: #subclasses)) flatten do: [:class| | instance | instance := class new: 10. instance first isColor ifTrue: [1 to: instance size do: [:i| instance at: i put: (Color r: i * 1 g: i * 2 b: i * 3)]] ifFalse: [1 to: instance size do: [:i| instance at: i put: i]]. self assert: instance equals: (self testObject: instance) description: 'A ', class name, ' should be serializable']
see Tests-eem.494
Best, Marcel
--
_,,,^..^,,,_
best, Eliot
On Tue, Nov 22, 2022 at 4:54 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi Eliot --
Write a test :-)
My image freezes. It seems totally broken. That's why I asked. I wanted to learn more about the expected behavior. After that, I could write a test. ;-)
Interesting! The test worked second time for me (I used "instance first class = Color", which is false since in that case "instance first class = TransparentColor :-) ). That's 64 bits macOS.
Are you seeing this on 32-bit Windows? or...?
Best, Marcel
Am 22.11.2022 13:50:30 schrieb Eliot Miranda eliot.miranda@gmail.com: Hi Marcel,
On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi all --
Should the following work?
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
Write a test :-)
testRawBits ((RawBitsArray subclasses reject: #isAbstract), ((RawBitsArray subclasses select: #isAbstract) collect: #subclasses)) flatten do: [:class| | instance | instance := class new: 10. instance first isColor ifTrue: [1 to: instance size do: [:i| instance at: i put: (Color r: i * 1 g: i * 2 b: i * 3)]] ifFalse: [1 to: instance size do: [:i| instance at: i put: i]]. self assert: instance equals: (self testObject: instance) description: 'A ', class name, ' should be serializable']
see Tests-eem.494
Best, Marcel
-- _,,,^..^,,,_ best, Eliot
Hi Eliot --
The test worked second time for me ...
Well, you wrote a test that does not account for the example I provided in my first e-mail. ;-) Maybe I used the wrong API. I combined #nextPut: with #nextArray. Looks reasonable to me.
The code in DataStreamTest looks scary: #testObject: #get: #put: #unStream: #streamedRepresentationOf: ... oh my ...
Best, Marcel Am 22.11.2022 13:57:19 schrieb Eliot Miranda eliot.miranda@gmail.com:
On Tue, Nov 22, 2022 at 4:54 AM Marcel Taeumel <marcel.taeumel@hpi.de [mailto:marcel.taeumel@hpi.de]> wrote:
Hi Eliot --
Write a test :-)
My image freezes. It seems totally broken. That's why I asked. I wanted to learn more about the expected behavior. After that, I could write a test. ;-)
Interesting! The test worked second time for me (I used "instance first class = Color", which is false since in that case "instance first class = TransparentColor :-) ). That's 64 bits macOS.
Are you seeing this on 32-bit Windows? or...?
Best, Marcel Am 22.11.2022 13:50:30 schrieb Eliot Miranda <eliot.miranda@gmail.com [mailto:eliot.miranda@gmail.com]>: Hi Marcel,
On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel <marcel.taeumel@hpi.de [mailto:marcel.taeumel@hpi.de]> wrote:
Hi all --
Should the following work?
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
Write a test :-)
testRawBits ((RawBitsArray subclasses reject: #isAbstract), ((RawBitsArray subclasses select: #isAbstract) collect: #subclasses)) flatten do: [:class| | instance | instance := class new: 10. instance first isColor ifTrue: [1 to: instance size do: [:i| instance at: i put: (Color r: i * 1 g: i * 2 b: i * 3)]] ifFalse: [1 to: instance size do: [:i| instance at: i put: i]]. self assert: instance equals: (self testObject: instance) description: 'A ', class name, ' should be serializable']
see Tests-eem.494
Best, Marcel
--
_,,,^..^,,,_
best, Eliot
--
_,,,^..^,,,_
best, Eliot
Le mar. 22 nov. 2022 à 14:01, Marcel Taeumel marcel.taeumel@hpi.de a écrit :
Hi Eliot --
The test worked second time for me ...
Well, you wrote a test that does not account for the example I provided in my first e-mail. ;-) Maybe I used the wrong API. I combined #nextPut: with #nextArray. Looks reasonable to me.
The code in DataStreamTest looks scary: #testObject: #get: #put: #unStream: #streamedRepresentationOf: ... oh my ...
Well, you have used readArray which is marked as private in comment, and will fail because we did not write an Array... (i would recommend to classify those methods in a private category/protocol) The example should use next instead, in which case it works for me.
Best, Marcel
Am 22.11.2022 13:57:19 schrieb Eliot Miranda eliot.miranda@gmail.com:
On Tue, Nov 22, 2022 at 4:54 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi Eliot --
Write a test :-)
My image freezes. It seems totally broken. That's why I asked. I wanted to learn more about the expected behavior. After that, I could write a test. ;-)
Interesting! The test worked second time for me (I used "instance first class = Color", which is false since in that case "instance first class = TransparentColor :-) ). That's 64 bits macOS.
Are you seeing this on 32-bit Windows? or...?
Best, Marcel
Am 22.11.2022 13:50:30 schrieb Eliot Miranda eliot.miranda@gmail.com: Hi Marcel,
On Tue, Nov 22, 2022 at 1:58 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hi all --
Should the following work?
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
Write a test :-)
testRawBits ((RawBitsArray subclasses reject: #isAbstract), ((RawBitsArray subclasses select: #isAbstract) collect: #subclasses)) flatten do: [:class| | instance | instance := class new: 10. instance first isColor ifTrue: [1 to: instance size do: [:i| instance at: i put: (Color r: i * 1 g: i * 2 b: i * 3)]] ifFalse: [1 to: instance size do: [:i| instance at: i put: i]]. self assert: instance equals: (self testObject: instance) description: 'A ', class name, ' should be serializable']
see Tests-eem.494
Best, Marcel
-- _,,,^..^,,,_ best, Eliot
-- _,,,^..^,,,_ best, Eliot
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".
Dave
Aha! Thanks for the clarification! :-)
Best, Marcel Am 23.11.2022 03:54:55 schrieb David T. Lewis lewis@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".
Dave
Hmm... 1024 bytes in a ByteArray will be 1029 bytes on disk. So it's okay, I suppose. Interestingly, a DoubleByteArray is use 5142 bytes on disk. A WordArray uses 4101 bytes hmm... okay. Strange for the DoubleByteArray though...
Am 23.11.2022 11:13:09 schrieb Marcel Taeumel marcel.taeumel@hpi.de: Aha! Thanks for the clarification! :-)
Best, Marcel Am 23.11.2022 03:54:55 schrieb David T. Lewis lewis@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".
Dave
Hi Marcel,
On Wed, Nov 23, 2022 at 2:20 AM Marcel Taeumel marcel.taeumel@hpi.de wrote:
Hmm... 1024 bytes in a ByteArray will be 1029 bytes on disk. So it's okay, I suppose. Interestingly, a DoubleByteArray is use 5142 bytes on disk. A WordArray uses 4101 bytes hmm... okay. Strange for the DoubleByteArray though...
IIRC these files include textual Smalltalk code for certain post-processing operations (if not, I apologise). So it may be worth-while "reading" the file in the FileList and seeing if there are any obvious differences between the generated files. I expect that there are a small set of privileged classes that have special support while others get more voluminous support.
Am 23.11.2022 11:13:09 schrieb Marcel Taeumel marcel.taeumel@hpi.de: Aha! Thanks for the clarification! :-)
Best, Marcel
Am 23.11.2022 03:54:55 schrieb David T. Lewis lewis@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".
Dave
squeak-dev@lists.squeakfoundation.org