Re: random maddening bug - "corrupted" file upload contents

Cyrille Delaunay <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <CAMEdb_AVQ5S3EC_0VBBS1MsdWVLXfNJ_8nzPEgB+egvhupYt3Q@mail.gmail.com>
thanks bob for digging into this issue.
if I sum up what I understood from your debugging and test session:

=> a corruption occurs while reading an input stream with method ZnUtils
class>>readUpToEnd:limit:
You confirm that the corruption alter the first 4 bytes of the input stream

=> the first 4 bytes are initially correctly written to an outputStream.
But, the first 4 bytes of this outputStream gets altered (corrupted) when
the inner byte array grows from 18184052 to 22732263
The grow of the inner byte array would be automatically triggered by
execution of method: #next:putAll:startingAt:

=> You have been able to write a piece of code that highlight this issue
(still randomely)


So the lower level method (that we have been able to spot) triggering an
unexpected behavior  would be #next:putAll:startingAt:
Am I Right ?
So we would start to dive into the guts of Pharo.

Should I open an issue somewhere ?




2018-01-11 2:41 GMT+01:00 Bob Arning <[email protected]>:

> I've been able to boil it down to one method. This fails sometimes and
> succeeds sometimes. Whichever it does, it tends to keep doing that for a
> while. Quitting and restarting may get it to change.
>
> test4
> "
> self test4
> "
>     | species bufferSize buffer totalRead outputStream answer inputStream
> ba byte1 |
>
>     false ifTrue: [
>         ba := (FileStream readOnlyFileNamed: '/Users/bob/z99.zip') binary;
> contentsOfEntireFile.
>      ] ifFalse: [
>         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 firstByte ifFalse: [ self halt ].
>     ].
>     answer := outputStream ifNil: [ species new ] ifNotNil: [ outputStream
> contents ].
>     byte1 = answer first ifFalse: [ self halt ].
>     ^answer
>
> On 1/10/18 4:42 AM, Cyrille Delaunay wrote:
>
>
> Has anyone been able to reproduce my little scenario ?
> As a reminder, suspicion is that something "wrong" has been introduced
> with Pharo6
>
>
>
> _______________________________________________
> seaside mailing list
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>


-- 
Cyrille Delaunay

_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.