[BUG] GP Fault using collect:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[BUG] GP Fault using collect:

Chris Double-2
A small bug (I think) in Dolphin 4, patch level 1, Windows 98.

Evaluate the following in a workspace:

  a := ByteArray with: 65 with: 66.
  a collect: [:e | e asCharacter ].

The last line gives the following walkback:

  ProcessorScheduler>>gpFault:
  [] in ProcessorScheduler>>vmi:list:no:with:
  BlockClosure>>ifCurtailed:
  ProcessorScheduler>>vmi:list:no:with:
  ByteArray(Object)>>errorAt:put:
  ByteArray(ArrayedCollection)>>at:put:
  [] in ByteArray(SequenceableCollection)>>collect:
  ByteArray(SequenceableCollection)>>from:to:keysAndValuesDo:
  ByteArray(SequenceableCollection)>>keysAndValuesDo:
  ByteArray(SequenceableCollection)>>collect:
  [...etc...]

I know the example is an error. The ByteArray can't hold characters
and #collect will create a new ByteArray with the block attempting to
put characters into it. A GP fault error seems a bit odd for this one
though rather than some type error?

I did this by accident and it took me a couple of looks to work out
why the error.

Cheers,
Chris.


Reply | Threaded
Open this post in threaded view
|

Re: [BUG] GP Fault using collect:

Andy Bower
Chris,

>   a := ByteArray with: 65 with: 66.
>   a collect: [:e | e asCharacter ].

As far as I'm aware you shouldn't expect this to work. #collect: is defined
as answering the same type of collection as the receiver (in this case a
ByteArray) which, in turn, is not capable of holding characters.

Okay, the error message is poor (for example Squeak gives "Error: Improper
store into indexable object" if you try this) but the GP fault is safely
trapped by Dolphin so no damage is done.

Note that the following works fine:

a := ByteArray with: 65 with: 66.
a asArray collect: [:e | e asCharacter ].

Best regards,

Andy Bower
Dolphin Support
http://www.object-arts.com

---
Visit the Dolphin Smalltalk Wiki Web
http://www.object-arts.com/wiki/html/Dolphin/FrontPage.htm
---

"Chris Double" <[hidden email]> wrote in message
news:[hidden email]...

> A small bug (I think) in Dolphin 4, patch level 1, Windows 98.
>
> Evaluate the following in a workspace:
>
>   a := ByteArray with: 65 with: 66.
>   a collect: [:e | e asCharacter ].
>
> The last line gives the following walkback:
>
>   ProcessorScheduler>>gpFault:
>   [] in ProcessorScheduler>>vmi:list:no:with:
>   BlockClosure>>ifCurtailed:
>   ProcessorScheduler>>vmi:list:no:with:
>   ByteArray(Object)>>errorAt:put:
>   ByteArray(ArrayedCollection)>>at:put:
>   [] in ByteArray(SequenceableCollection)>>collect:
>   ByteArray(SequenceableCollection)>>from:to:keysAndValuesDo:
>   ByteArray(SequenceableCollection)>>keysAndValuesDo:
>   ByteArray(SequenceableCollection)>>collect:
>   [...etc...]
>
> I know the example is an error. The ByteArray can't hold characters
> and #collect will create a new ByteArray with the block attempting to
> put characters into it. A GP fault error seems a bit odd for this one
> though rather than some type error?
>
> I did this by accident and it took me a couple of looks to work out
> why the error.
>
> Cheers,
> Chris.


Reply | Threaded
Open this post in threaded view
|

Re: [BUG] GP Fault using collect:

Chris Double-2
"Andy Bower" <[hidden email]> writes:

> As far as I'm aware you shouldn't expect this to work. #collect: is
> defined as answering the same type of collection as the receiver (in
> this case a ByteArray) which, in turn, is not capable of holding
> characters.

Thanks Andy, I'd cottened on to that being the problem. The real event
where it happened I didn't know what the collection type was - until
the error of course. For future, can I safely assume then that a
trapped GP fault like this won't harm my image and I can continue ok?

BTW, thanks for the fast response.

Cheers,
Chris.
--
http://www.double.co.nz/smalltalk