On 03/25/2011 03:11 PM, Holger Hans Peter Freyther wrote:
On 03/25/2011 02:59 PM, Paolo Bonzini wrote:

I mean, are you sure the primitive isn't failing because for example
aCollection is bogus?  I mean, this crashes the VM:

hmm... I assume it is valid as I go through the normal Socket>>#atEnd.

I guess I didn't explain myself very well...

st> (FileDescriptor on: 0) nextAvailable: 1 into: nil startingAt: 1

Object: nil error: did not understand #+
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
UndefinedObject(Object)>>doesNotUnderstand: #+ (SysExcept.st:1407)
FileDescriptor>>nextAvailable:into:startingAt: (FileDescr.st:802)
UndefinedObject>>executeStatements (a String:1)
nil

Does this patch help, or otherwise change the failure?

diff --git a/packages/sockets/Buffers.st b/packages/sockets/Buffers.st
index 8eb4dcd..2084797 100644
--- a/packages/sockets/Buffers.st
+++ b/packages/sockets/Buffers.st
@@ -46,6 +46,12 @@ collection.'>
        ptr := 1
     ]

+    close [
+       <category: 'buffer handling'>
+        super close.
+        flushBlock := nil
+    ]
+
     flushBlock: block [
        "Set which block will be used to flush the buffer.
         The block will be evaluated with a collection and
@@ -119,6 +125,12 @@ evaluates an user defined block to try to get some more data.'>
            yourself    "Force a buffer load soon"
     ]

+    close [
+       <category: 'buffer handling'>
+        super close.
+        fillBlock := nil
+    ]
+
     atEnd [
        "Answer whether the data stream has ended."

diff --git a/packages/sockets/Sockets.st b/packages/sockets/Sockets.st
index ea11feb..c6358cd 100644
--- a/packages/sockets/Sockets.st
+++ b/packages/sockets/Sockets.st
@@ -1318,6 +1318,7 @@ This class adds a read buffer to the basic model of AbstractSocket.'>
        <category: 'private - buffering'>
        ^(ReadBuffer on: (String new: size)) fillBlock:
                [:data :size || n |
+                data isNil ifTrue: [self halt].
                self implementation ensureReadable.
                n := self implementation isOpen
ifTrue: [self implementation nextAvailable: size into: data startingAt: 1] @@ -1459,6 +1460,7 @@ This class adds read and write buffers to the basic model of AbstractSocket.'>
        ^(WriteBuffer on: (String new: size)) flushBlock:
                [:data :size |
                | alive |
+                data isNil ifTrue: [self halt].
                self implementation ensureWriteable.
                alive := self implementation isOpen
and: [(self implementation next: size putAll: data startingAt: 1) > -1].



I'll apply the Buffers.st part since it's good anyway.

should the vm crash? patches welcome?

no, it shouldn't.  patch on the way.

st>  (FileDescriptor on: 0) nextAvailable: 1 into: 123 startingAt: 1

stdin:4: Aborted
(ip 80)FileDescriptor>>#nextAvailable:into:startingAt:
(ip 14)UndefinedObject>>#executeStatements
(ip 0)<bottom>
Aborted

:)

Paolo


_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to