VM crash

Klaus D. Witzel klaus.witzel at cobss.com
Sun Jun 4 22:48:42 UTC 2006


On Mon, 05 Jun 2006 00:35:40 +0200, tim Rowledge <tim at rowledge.org> wrote:
>
> On 4-Jun-06, at 3:05 PM, Bert Freudenberg wrote:
>
>> Am 04.06.2006 um 23:42 schrieb Jecel Assumpcao Jr:
>>
>>> Bob Cowdery wrote on Sun, 4 Jun 2006 13:12:12 +0100
>>>
>>>>         memcpy((void *)results, a, 4096*sizeof(float));
>>>
>>> I haven't looked into interfacing with the VM at all and so am probably
>>> saying something really stupid, but I would think that results[0] would
>>> hold the object's header and overwritting it would cause really bad
>>> things to happen.
>>
>> That's what I suspected, too.
>>
>> So, you have to convert between Oops and C pointers, for example using  
>> #arrayValueOf: if you know your Oop is an array, or  
>> #firstIndexableField: for the general case. Also, be sure to look at  
>> the generated C code, and attach it for reference.
>
> The plugin function is generated as:-
>
> EXPORT(sqInt) test(void) {
> 	float *data;
>
> 	data = ((float *) (interpreterProxy->arrayValueOf(interpreterProxy- 
>  >stackValue(0))));
> 	if (interpreterProxy->failed()) {
> 		return null;
> 	}
> 	process_test(data);
> 	if (interpreterProxy->failed()) {
> 		return null;
> 	}
> 	interpreterProxy->popthenPush(2, data);
> 	return null;
> }
>
> so we can see it is handling the firstIndexableField issue via  
> arrayValueOf().

Sure. But interpreterProxy->popthenPush(2, data); is not the converse of

  data = ((float *)  
(interpreterProxy->arrayValueOf(interpreterProxy->stackValue(0))));

, simply because data is not an oop.

/Klaus




More information about the Squeak-dev mailing list