[Vm-dev] [Pharo-dev] Random corrupted data when copying from very large byte array

Stuart Cassoff aa72 at bell.net
Tue Jan 23 20:33:00 UTC 2018


Thanks! Yeah, sorry, I couldn't find the original thread.
Anyway I don't really know what to do with this so I pasted into a workspace and hit alt-p.
After a while I get a debug popup telling me about something not understanding 'halt'.
fyi I've not yet written a line of Smalltalk code in my life so maybe I'm biting off more than I can chew.
I get the impression I should make a method 'test4' in some number class. *shrug*
Anyway, here's part of the SqueakDebug.log that may be useful.

Stu


UndefinedObject>>DoIt
        Receiver: nil
        Arguments and temporary variables: 
                species:        ByteArray
                bufferSize:     16384
                buffer:         #[99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 ...etc...
                totalRead:      18202085
                outputStream:   a WriteStream
                answer:         #[99 99 99 99 10 7 7 7 7 7 125 83 67 73 7 7 7 7 7 7 99 99 99 99 99 99 9...etc...
                inputStream:    a ReadStream
                ba:     #[80 75 3 4 10 7 7 7 7 7 125 83 67 73 7 7 7 7 7 7 99 99 99 99 99 99 99 99 9...etc...
                byte1:  80
                i:      21
                readCount:      15845
        Receiver's instance variables: 
nil


> ---------- Original Message ----------
> From: Alistair Grant <akgrant0710 at gmail.com>
> Date: January 23, 2018 at 10:40 AM
> 
> 
> Hi Stu,
> 
> On 23 January 2018 at 16:15, Stuart Cassoff <aa72 at bell.net> wrote:
> >
> > I'm curious to test both of these problems on obsd but don't know what to do to make the problem manifest itself, so if anyone could toss me a (preferably non-null) pointer, that'd be great.
> >
> >
> > Thanks,
> >
> > Stu
> 
> Just run #test4 (several times :-)) as defined in the original post.
> 
> 
> Cheers,
> Alistair
> --
> 
> test4
> "self test4"
> | species bufferSize buffer totalRead outputStream answer inputStream ba byte1 |
>             ba := ByteArray new: 18202085.        ba atAllPut: 99.
>    1 to: 20 do: [  :i | ba at: i put: (#[80 75 3 4 10 7 7 7 7 7 125 83
> 67 73 7 7 7 7 7 7] at: i) ].    inputStream := ba readStream.
> bufferSize := 16384.    species := ByteArray.
>     buffer := species new: bufferSize.
>     totalRead := 0.
>     outputStream := nil.
>     [ inputStream atEnd ] whileFalse: [ | readCount |
>         readCount := inputStream readInto: buffer startingAt: 1 count:
> bufferSize.
>         totalRead = 0 ifTrue: [
>             byte1 := buffer first.
>         ].
>         totalRead := totalRead + readCount.
> 
>         outputStream ifNil: [
>             inputStream atEnd
>                 ifTrue: [ ^ buffer copyFrom: 1 to: readCount ]
>                 ifFalse: [ outputStream := (species new: bufferSize)
> writeStream ] ].
>         outputStream next: readCount putAll: buffer startingAt: 1.
>         byte1 = outputStream contents first ifFalse: [ self halt ].
>     ].
>     answer := outputStream ifNil: [ species new ] ifNotNil: [
> outputStream contents ].
>     byte1 = answer first ifFalse: [ self halt ].    ^answer
> --


More information about the Vm-dev mailing list