[PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

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

[PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

Holger Freyther

Instead of crashing the VM we will fail the primitive if a type
can not be converted from Smalltalk to C. The code attempts to
free all data allocated for this primitive.

2011-02-04  Holger Hans Peter Freyther  <[hidden email]>

        * libgst/cint.c: Propagate type conversion failures.

2011-02-04  Holger Hans Peter Freyther  <[hidden email]>

        * UnitTest.st: Verify that the primitive are failing.

Signed-off-by: Holger Hans Peter Freyther <[hidden email]>
---
 ChangeLog                    |    4 +++
 libgst/cint.c                |   51 +++++++++++++++++++++++++++++------------
 packages/sockets/ChangeLog   |    4 +++
 packages/sockets/UnitTest.st |   15 ++++++++++++
 4 files changed, 59 insertions(+), 15 deletions(-)



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

0003-cint-Fail-the-VMpr_CFuncDescriptor_call-primitive-wi.patch (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

Holger Freyther
On 02/04/2011 10:28 PM, Holger Hans Peter Freyther wrote:
> +cleanup:
> +  /* Attempt to cleanup all pushing of arguments. We have tried to
> +     write at si and now need to cleanup up until this point. */
> +  for (i = 0, arg = local_arg_vec; i < si; i++, arg++)


okay the < si is wrong...i should probably use c_func_cur->arg_idx or such. I
will create another testcase that can be used to verify we are not leaking
memory here.

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

Holger Freyther
In reply to this post by Holger Freyther
On 02/04/2011 10:28 PM, Holger Hans Peter Freyther wrote:

> +    testDoNotCrashWithWrongTypes [
> +        "The objective is to see if wrong types for a cCallout will
> +         make the VM crash or not. It should also check if these calls
> +         raise the appropriate exception."
> +        | socket impl |
> +
> +        socket := DatagramSocket new.
> +        impl := socket implementation.
> +
> +        self should: [impl accept: -1 peer: nil addrLen: 0] raise: SystemExceptions.PrimitiveFailed.
> +        self should: [impl getPeerName: -1 addr: nil addrLen: 0] raise: SystemExceptions.PrimitiveFailed.
> +        self should: [impl getSockName: -1 addr: nil addrLen: 0] raise: SystemExceptions.PrimitiveFailed.
> +        self should: [impl receive: -1 buffer: nil size: 0 flags: 0 from: nil size: 0] raise: SystemExceptions.PrimitiveFailed.
> +    ]
>  ]


this fails from within the testsuite as it is generating stderr output. Is
this something we can handle in autotest?


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

Paolo Bonzini-2
On 02/04/2011 10:52 PM, Holger Hans Peter Freyther wrote:

> On 02/04/2011 10:28 PM, Holger Hans Peter Freyther wrote:
>> +    testDoNotCrashWithWrongTypes [
>> +        "The objective is to see if wrong types for a cCallout will
>> +         make the VM crash or not. It should also check if these calls
>> +         raise the appropriate exception."
>> +        | socket impl |
>> +
>> +        socket := DatagramSocket new.
>> +        impl := socket implementation.
>> +
>> +        self should: [impl accept: -1 peer: nil addrLen: 0] raise: SystemExceptions.PrimitiveFailed.
>> +        self should: [impl getPeerName: -1 addr: nil addrLen: 0] raise: SystemExceptions.PrimitiveFailed.
>> +        self should: [impl getSockName: -1 addr: nil addrLen: 0] raise: SystemExceptions.PrimitiveFailed.
>> +        self should: [impl receive: -1 buffer: nil size: 0 flags: 0 from: nil size: 0] raise: SystemExceptions.PrimitiveFailed.
>> +    ]
>>   ]
>
> this fails from within the testsuite as it is generating stderr output. Is
> this something we can handle in autotest?

I'll make it XFAIL for now.  For 3.3 we can change the PrimitiveFailed
to invoke a Smalltalk implementation of the type checks and raise a
proper exception.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

Paolo Bonzini-2
In reply to this post by Holger Freyther
On 02/04/2011 10:40 PM, Holger Hans Peter Freyther wrote:
> okay the<  si is wrong...i should probably use c_func_cur->arg_idx or such. I
> will create another testcase that can be used to verify we are not leaking
> memory here.

Please send an incremental 4/3 patch and I'll squash it into this one.
Thanks!

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/3] cint: Fail the VMpr_CFuncDescriptor_call primitive with wrong args

Holger Freyther
In reply to this post by Paolo Bonzini-2
On 02/05/2011 04:29 PM, Paolo Bonzini wrote:

> I'll make it XFAIL for now.  For 3.3 we can change the PrimitiveFailed to
> invoke a Smalltalk implementation of the type checks and raise a proper
> exception.

It fails because we don't ignore the stderr output... e.g. this will make the
test case pass. I will put that into another patch... so you can put this
before the cint patch.

diff --git a/tests/local.at b/tests/local.at
index 49f9111..7dedf2c 100755
--- a/tests/local.at
+++ b/tests/local.at
@@ -64,7 +64,7 @@ m4_define([AT_OPTIONAL_PACKAGE_TEST], [
     case $ret in
       2) exit 77 ;;
       0|1) exit $ret ;;
-    esac], [], [], [ignore])
+    esac], [], [], [ignore], [ignore])
   AT_CLEANUP
 ])


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