FFI+Linux+double return value

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

FFI+Linux+double return value

Schwab,Wilhelm K
Hello all,

I had some strange results with double return values and boiled it down to a C function

Double AnyDouble()
{
        return 1.0;
}

called via

  anyDouble
  < cdecl: double 'AnyDouble' () >

and driven by

| out |
out := Array writeStream.
100 timesRepeat:[
  out nextPut:Library default anyDouble
].
out contents.

The results are not good.  It works for the first three elements, after which it produces NaN.  The real problem appears to be comparison of floats being broken after that point, as evidenced by a walkback that arises when trying to inspect the resulting collection - exploring it works.

I need to try this on the latest image/vm, but wanted to start gathering opinions.  Any ideas?

Bill



Reply | Threaded
Open this post in threaded view
|

Re: FFI+Linux+double return value

Nicolas Cellier
That reminds me something like http://bugs.squeak.org/view.php?id=3929
This did happen on linux only.

Are you on linux ?
Which VM ?
Can you check VM sources ?

Nicolas

2010/4/6 Schwab,Wilhelm K <[hidden email]>:

> Hello all,
>
> I had some strange results with double return values and boiled it down to a C function
>
> Double AnyDouble()
> {
>        return 1.0;
> }
>
> called via
>
>  anyDouble
>  < cdecl: double 'AnyDouble' () >
>
> and driven by
>
> | out |
> out := Array writeStream.
> 100 timesRepeat:[
>  out nextPut:Library default anyDouble
> ].
> out contents.
>
> The results are not good.  It works for the first three elements, after which it produces NaN.  The real problem appears to be comparison of floats being broken after that point, as evidenced by a walkback that arises when trying to inspect the resulting collection - exploring it works.
>
> I need to try this on the latest image/vm, but wanted to start gathering opinions.  Any ideas?
>
> Bill
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

RE: FFI+Linux+double return value

Schwab,Wilhelm K
In reply to this post by Schwab,Wilhelm K
Nicolas,

I am running this on Ubuntu (9.10) and have been using the Pharo 0.15.2f vm.  I just tried a Squeak vm (3.11-3) and could not get it to load my library.  I have been using an absolute path the the .so; could that be the problem with the Squeak vm??

There has been a lot of discussion of the Pharo Linux vm lately, with some links and corrections, so I'll have to look around a little.

You asked if I can check the vm sources; the concern is whether or not I will have anything to add :)  Is there something specific you want me to do?

Bill


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Schwab,Wilhelm K
Sent: Tuesday, April 06, 2010 1:46 PM
To: [hidden email]; The general-purpose Squeak developers list
Subject: [Pharo-project] FFI+Linux+double return value

Hello all,

I had some strange results with double return values and boiled it down to a C function

Double AnyDouble()
{
        return 1.0;
}

called via

  anyDouble
  < cdecl: double 'AnyDouble' () >

and driven by

| out |
out := Array writeStream.
100 timesRepeat:[
  out nextPut:Library default anyDouble
].
out contents.

The results are not good.  It works for the first three elements, after which it produces NaN.  The real problem appears to be comparison of floats being broken after that point, as evidenced by a walkback that arises when trying to inspect the resulting collection - exploring it works.

I need to try this on the latest image/vm, but wanted to start gathering opinions.  Any ideas?

Bill



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply | Threaded
Open this post in threaded view
|

RE: FFI+Linux+double return value

Nicolas Cellier
2010/4/6 Schwab,Wilhelm K <[hidden email]>:

> Nicolas,
>
> I am running this on Ubuntu (9.10) and have been using the Pharo 0.15.2f vm.  I just tried a Squeak vm (3.11-3) and could not get it to load my library.  I have been using an absolute path the the .so; could that be the problem with the Squeak vm??
>
> There has been a lot of discussion of the Pharo Linux vm lately, with some links and corrections, so I'll have to look around a little.
>
> You asked if I can check the vm sources; the concern is whether or not I will have anything to add :)  Is there something specific you want me to do?
>
> Bill
>

Well, http://bugs.squeak.org/view.php?id=3929 seems fixed in 3.11-3
though... See release notes at
http://www.squeakvm.org/cgi-bin/viewcvs.cgi/trunk/platforms/unix/doc/RELEASE_NOTES_3.11.3.2135?rev=2138&view=auto

It says:
FFI tweaked on Linux to avoid a potential FPU stack overflow.

It also says that some black magic has been removed for library search.
So you'll have to define LD_LIBRARY_PATH before lauching squeak
In bash:
LD_LIBRARY_PATH=/your_path_here  squeak  your_image.image

Nicolas

>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Schwab,Wilhelm K
> Sent: Tuesday, April 06, 2010 1:46 PM
> To: [hidden email]; The general-purpose Squeak developers list
> Subject: [Pharo-project] FFI+Linux+double return value
>
> Hello all,
>
> I had some strange results with double return values and boiled it down to a C function
>
> Double AnyDouble()
> {
>        return 1.0;
> }
>
> called via
>
>  anyDouble
>  < cdecl: double 'AnyDouble' () >
>
> and driven by
>
> | out |
> out := Array writeStream.
> 100 timesRepeat:[
>  out nextPut:Library default anyDouble
> ].
> out contents.
>
> The results are not good.  It works for the first three elements, after which it produces NaN.  The real problem appears to be comparison of floats being broken after that point, as evidenced by a walkback that arises when trying to inspect the resulting collection - exploring it works.
>
> I need to try this on the latest image/vm, but wanted to start gathering opinions.  Any ideas?
>
> Bill
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>