FFI-Tests initialization problem

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

FFI-Tests initialization problem

Nicolas Cellier
 
Hi all,
I defined new FFI-Tests with struct inside struct.
I wanted to check for correct alignment (this works as it should thanks to Ronie!).

But when I reload the package into a new image, there is an initialization order problem.
It seems that the struct FFITestSfd is created AFTER the struct FFITestSsSfd.
But struct FFITestSsSfd depends on struct FFITestSfd (it is just struct {short s1; struct FFITestSfd sfd2;}
Consequently, FFITestSsSfd DOES not get correctly initialized...
It simply ignore the missing FFITestSfd definition, and believes that it has a single field (short s1) and that it is of size 2...

When we execute the FFIPluginTests testSuite, this can badly crash the image because the FFI is allocating a ByteArray handle of size 2 for returning the FFITestSsSfd by value, and the test function writes a struct of size 12 into it...

We can't live long with such hanging sword above our heads and should urgently fix it.
At least, you are warned, don't execute new FFI tests blindly.
Reply | Threaded
Open this post in threaded view
|

Re: FFI-Tests initialization problem

Eliot Miranda-2
 
Hi Nicolas,

    I can't reproduce this because FFITestSfd  & FFITestSsSfd et al are not yet in FFI_Tests.  Can you co bit them to FFI_Tests?  You can put it in FFIinbox if you don't feel comfortable putting it straight in FFI.

On Sun, Jan 26, 2020 at 1:38 PM Nicolas Cellier <[hidden email]> wrote:
 
Hi all,
I defined new FFI-Tests with struct inside struct.
I wanted to check for correct alignment (this works as it should thanks to Ronie!).

But when I reload the package into a new image, there is an initialization order problem.
It seems that the struct FFITestSfd is created AFTER the struct FFITestSsSfd.
But struct FFITestSsSfd depends on struct FFITestSfd (it is just struct {short s1; struct FFITestSfd sfd2;}
Consequently, FFITestSsSfd DOES not get correctly initialized...
It simply ignore the missing FFITestSfd definition, and believes that it has a single field (short s1) and that it is of size 2...

When we execute the FFIPluginTests testSuite, this can badly crash the image because the FFI is allocating a ByteArray handle of size 2 for returning the FFITestSsSfd by value, and the test function writes a struct of size 12 into it...

We can't live long with such hanging sword above our heads and should urgently fix it.
At least, you are warned, don't execute new FFI tests blindly.


--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|

Re: FFI-Tests initialization problem

Nicolas Cellier
 
Hi Eliot,
yes, in the meantime I have published https://source.squeak.org/FFI/FFI-Tests-nice.12.diff with a postscript workaround.

Le dim. 26 janv. 2020 à 23:39, Eliot Miranda <[hidden email]> a écrit :
 
Hi Nicolas,

    I can't reproduce this because FFITestSfd  & FFITestSsSfd et al are not yet in FFI_Tests.  Can you co bit them to FFI_Tests?  You can put it in FFIinbox if you don't feel comfortable putting it straight in FFI.

On Sun, Jan 26, 2020 at 1:38 PM Nicolas Cellier <[hidden email]> wrote:
 
Hi all,
I defined new FFI-Tests with struct inside struct.
I wanted to check for correct alignment (this works as it should thanks to Ronie!).

But when I reload the package into a new image, there is an initialization order problem.
It seems that the struct FFITestSfd is created AFTER the struct FFITestSsSfd.
But struct FFITestSsSfd depends on struct FFITestSfd (it is just struct {short s1; struct FFITestSfd sfd2;}
Consequently, FFITestSsSfd DOES not get correctly initialized...
It simply ignore the missing FFITestSfd definition, and believes that it has a single field (short s1) and that it is of size 2...

When we execute the FFIPluginTests testSuite, this can badly crash the image because the FFI is allocating a ByteArray handle of size 2 for returning the FFITestSsSfd by value, and the test function writes a struct of size 12 into it...

We can't live long with such hanging sword above our heads and should urgently fix it.
At least, you are warned, don't execute new FFI tests blindly.


--
_,,,^..^,,,_
best, Eliot