Adrian Victor Crisciu | 22 Jul 15:38 2013
Picon

GHC and GSL

Hi,

I need to import in one of my programs the minimization module form Numeric.GSL.Minimization. When I run even the example code in interactive mode, ghci crashes with a "Bus error" message. Is this a bug, or is something wrong with my code?

The offending program follows:

module MinMaxTest where

import Numeric.GSL.Minimization

objFunc :: [Double] -> Double
objFunc [x, y] = 10 * (x-1)^2 + 20 * (y-2)^2 + 30

main :: IO ()
main = do
    let (s, p) = minimize NMSimplex2 1e-2 30 [1, 1] objFunc [5, 7]
    print s
    print p

I use ghc-7.6.3 on a Slackware-Linux platform.

Can anyone help?

Thank you in advance.
Adrian-Victor

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Edward Z. Yang | 22 Jul 18:27 2013
Picon

Re: GHC and GSL

Usually, a bus error is similar to a segmentation fault, in that it
indicates something has gone terribly wrong.  However, as hmatrix
is an API to some foreign C libraries, I would not rule out the possibility
that it's a bug in the library itself.

What version of hmatrix do you have, and if you compile the program
with -debug and run it in gdb, do you get a backtrace?

Edward

Excerpts from Adrian Victor Crisciu's message of Mon Jul 22 06:38:46 -0700 2013:
> Hi,
> 
> I need to import in one of my programs the minimization module form
> Numeric.GSL.Minimization. When I run even the example code in interactive
> mode, ghci crashes with a "Bus error" message. Is this a bug, or is
> something wrong with my code?
> 
> The offending program follows:
> 
> module MinMaxTest where
> 
> import Numeric.GSL.Minimization
> 
> objFunc :: [Double] -> Double
> objFunc [x, y] = 10 * (x-1)^2 + 20 * (y-2)^2 + 30
> 
> main :: IO ()
> main = do
>     let (s, p) = minimize NMSimplex2 1e-2 30 [1, 1] objFunc [5, 7]
>     print s
>     print p
> 
> I use ghc-7.6.3 on a Slackware-Linux platform.
> 
> Can anyone help?
> 
> Thank you in advance.
> Adrian-Victor
Alberto Ruiz | 22 Jul 18:40 2013
Picon

Re: GHC and GSL

I think this is known problem with interpreted mode in 64-bit machines:

https://github.com/albertoruiz/hmatrix/issues/2

The program should work ok in compiled mode.

Alberto

On 07/22/2013 06:27 PM, Edward Z. Yang wrote:
> Usually, a bus error is similar to a segmentation fault, in that it
> indicates something has gone terribly wrong.  However, as hmatrix
> is an API to some foreign C libraries, I would not rule out the possibility
> that it's a bug in the library itself.
>
> What version of hmatrix do you have, and if you compile the program
> with -debug and run it in gdb, do you get a backtrace?
>
> Edward
>
> Excerpts from Adrian Victor Crisciu's message of Mon Jul 22 06:38:46 -0700 2013:
>> Hi,
>>
>> I need to import in one of my programs the minimization module form
>> Numeric.GSL.Minimization. When I run even the example code in interactive
>> mode, ghci crashes with a "Bus error" message. Is this a bug, or is
>> something wrong with my code?
>>
>> The offending program follows:
>>
>> module MinMaxTest where
>>
>> import Numeric.GSL.Minimization
>>
>> objFunc :: [Double] -> Double
>> objFunc [x, y] = 10 * (x-1)^2 + 20 * (y-2)^2 + 30
>>
>> main :: IO ()
>> main = do
>>      let (s, p) = minimize NMSimplex2 1e-2 30 [1, 1] objFunc [5, 7]
>>      print s
>>      print p
>>
>> I use ghc-7.6.3 on a Slackware-Linux platform.
>>
>> Can anyone help?
>>
>> Thank you in advance.
>> Adrian-Victor
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users <at> haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
Greg Horn | 29 Jul 15:28 2013
Picon

Re: GHC and GSL

I ran into this a while ago and I think I fixed it by adding "cc-options: -fPIC" to the .cabal file.


On Mon, Jul 22, 2013 at 6:40 PM, Alberto Ruiz <aruiz <at> um.es> wrote:
I think this is known problem with interpreted mode in 64-bit machines:

https://github.com/albertoruiz/hmatrix/issues/2

The program should work ok in compiled mode.

Alberto


On 07/22/2013 06:27 PM, Edward Z. Yang wrote:
Usually, a bus error is similar to a segmentation fault, in that it
indicates something has gone terribly wrong.  However, as hmatrix
is an API to some foreign C libraries, I would not rule out the possibility
that it's a bug in the library itself.

What version of hmatrix do you have, and if you compile the program
with -debug and run it in gdb, do you get a backtrace?

Edward

Excerpts from Adrian Victor Crisciu's message of Mon Jul 22 06:38:46 -0700 2013:
Hi,

I need to import in one of my programs the minimization module form
Numeric.GSL.Minimization. When I run even the example code in interactive
mode, ghci crashes with a "Bus error" message. Is this a bug, or is
something wrong with my code?

The offending program follows:

module MinMaxTest where

import Numeric.GSL.Minimization

objFunc :: [Double] -> Double
objFunc [x, y] = 10 * (x-1)^2 + 20 * (y-2)^2 + 30

main :: IO ()
main = do
     let (s, p) = minimize NMSimplex2 1e-2 30 [1, 1] objFunc [5, 7]
     print s
     print p

I use ghc-7.6.3 on a Slackware-Linux platform.

Can anyone help?

Thank you in advance.
Adrian-Victor

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Adrian Victor Crisciu | 29 Jul 17:28 2013
Picon

Re: GHC and GSL

It worked! Thank you very much!

I added the following lines to hmatrix.cabal:

if os(linux)
     if arch(x86_64)
          cc-options: -fPIC

Maybe these lines should be included in future versions of the .cabal file.

Thank you very, very much!
Adrian-Victor
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Greg Horn | 29 Jul 17:36 2013
Picon

Re: GHC and GSL

You're welcome!

This might also be needed in OSX, but I don't remember.


On Mon, Jul 29, 2013 at 5:28 PM, Adrian Victor Crisciu <acrisciu <at> gmail.com> wrote:
It worked! Thank you very much!

I added the following lines to hmatrix.cabal:

if os(linux)
     if arch(x86_64)
          cc-options: -fPIC

Maybe these lines should be included in future versions of the .cabal file.

Thank you very, very much!
Adrian-Victor

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Brandon Allbery | 29 Jul 18:15 2013
Picon

Re: GHC and GSL

On Mon, Jul 29, 2013 at 11:36 AM, Greg Horn <gregmainland <at> gmail.com> wrote:
This might also be needed in OSX, but I don't remember.

OS X *always* builds PIC; a holdover from PPC where, while it was possible to build non-PIC, pretty much everything expected PIC even for static linking (it's part of the official PPC ABI). You have to put in some effort to make non-PIC code.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b <at> gmail.com                                  ballbery <at> sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users <at> haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Gmane