[Vm-dev] [CRASH] I am getting a segmentation fault calling my primitive

Robert Withers robert.withers at pm.me
Sat May 29 20:25:13 UTC 2021


I have an issue with:

> RSErasureGalois newGalois divide: 4 by: 2.

In the image I get 2. In the plugin I get 142, which is the value for index 255 in the expTable. My question is how can I printf to stdout, inside the plugin code. I tried adding some debug lines to the c code:

printf( "a: %i\n", a );
printf( "b: %i\n", b );
logA = logTable[a];
logB = logTable[b];
printf( "logA: %i\n", logA );
printf( "logB: %i\n", logB );
logResult = logA - logB;
while (logResult <= 0) {
logResult += 0xFF;
}
if (logResult == 0) {
return 1;
}
printf( "logResult: %i\n", logResult );
result = expTable[logResult];
printf( "result: %i\n", result );

This did not work, however. How can I debug the c code?

---
Kindly,
Robert

On 5/29/21 3:29 PM, Robert Withers wrote:

> I commented out these argument checks and regenerated and rebuilt the plugins. New plugins are attached.
>
> Now the RSErasureGaloisWithPlugin is working, for the following squeak calls.
>
>> RSErasureGalois newGalois... a RSErasureGaloisWithPlugin
>
>> self addOrSubtract: 2 by: 1. = 3
>> self divide: 4 by: 2. = 14
>> self exp: 3. = 8
>> self exp: 2 power: 2. = 4
>> self log: 4. = 2
>> self galoisMultiply: 2 by: 2. = 4
>> self tableMultiply: 2 by: 2. = 4
>
> I still have problems with the RSFECPlugin, calling methods in RSFECGenericGFWithPlugin:
>
>> RSFECGenericGF newPrimitive: 16r012D size: 256 generatorBase: 1... a RSFECGenericGFWithPlugin
>
>> self addOrSubtract: 2 by: 1. = 3
>> self exp: 3. {#primitiveFailed}
>> self inverse: 2. = 0
>> self log: 4. {#primitiveFailed}
>> self multiply: 2 by: 2. {#primitiveFailed}
>
> ---
> Kindly,
> Robert
>
> On 5/29/21 2:49 PM, Robert Withers wrote:
>
>> Could the issue be bounds checking in the primitive? But it is a seg-fault, not a #primitiveFailed. Thanks for any and all help! This one has me stumped.
>>
>>> ((interpreterProxy isBytes: a)
>>> and: [ (interpreterProxy stSizeOf: a) = 4 ])
>>> ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
>>> ((interpreterProxy isBytes: b)
>>> and: [ (interpreterProxy stSizeOf: b) = 4 ])
>>> ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
>>
>> ---
>> Kindly,
>> Robert
>>
>> On 5/29/21 2:42 PM, Robert Withers wrote:
>>
>>> Here is the RSErasurePlugin.so & RSFECPlugin.so so folks may be able to help me test the seg-fault with these plugin and loading the latest RSErasure code:
>>>
>>>> Installer ss
>>>> project: 'Cryptography';
>>>> install: 'ProCrypto-1-1-1';
>>>> install: 'ProCryptoTests-1-1-1'.
>>>
>>> Here is the code I run that leads to the seg-fault:
>>>
>>>> RSErasureGalois newGalois.
>>>
>>> ---
>>> Kindly,
>>> Robert
>>>
>>> On 5/29/21 2:37 PM, Robert Withers wrote:
>>>
>>>> Hey y'all,
>>>>
>>>> I am getting a segmentation fault calling primitiveGaloisMultiplyBy in
>>>> my RSErasurePlugin. I have attached the crash.dmp file.
>>>> Investigating...assistance requested. Grazie!!
>>>>
>>>> --
>>>> ---
>>>> Kindly,
>>>> Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20210529/9136895f/attachment.html>


More information about the Vm-dev mailing list