Re: Floating Point Exceptions

2016-12-07 Thread Carter Schonwald
Adding sigfpe handling doesn't have a writeupnyet because it's on my
holiday project queue and the specifics of doing it nicely depend somewhat
on the target architecture.

If you want to get good errors in the mean time, register a sigfpe signal
handler at the top level and invoke a smidge of c code to get info.

Granted this doesn't give you a stack trace ...

On Wed, Dec 7, 2016 at 11:52 AM Dominic Steinitz 
wrote:

> Hello again,
>
>
>
> I removed my dependency on hmatrix and enabled floating point exceptions
> via `feenableexcept` hoping to get a call stack showing me where the
> exception was being raised but alas all I get is
>
>
>
> > *Main> main
>
> > ghc: ghc-iserv terminated (-8)
>
> > Leaving GHCi.
>
>
>
>
>
> My googling didn’t turn up much but as far as I can tell ghc does *not*
> handle sigfpe (googling "haskell sigfpe” turns up blog posts on Haskell by
> someone called “sigfpe”). I think it would be jolly useful to be able to
> get stack traces of floating point exceptions. How much work would this be?
> I’d be happy to have a go at it if someone could provide help and guidance.
>
>
>
> There seems to have been some discussion of it on the ghc-devs mailing
> list in September (
> https://mail.haskell.org/pipermail/ghc-devs/2016-September/date.html) but
> not much in the way of write up.
>
>
>
> Dominic Steinitz
>
> domi...@steinitz.org
>
> http://idontgetoutmuch.wordpress.com
>
>
>
> ___
>
> Glasgow-haskell-users mailing list
>
> Glasgow-haskell-users@haskell.org
>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
>
>
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


Floating Point Exceptions

2016-12-07 Thread Dominic Steinitz
Hello again,

I removed my dependency on hmatrix and enabled floating point exceptions via 
`feenableexcept` hoping to get a call stack showing me where the exception was 
being raised but alas all I get is

> *Main> main
> ghc: ghc-iserv terminated (-8)
> Leaving GHCi.


My googling didn’t turn up much but as far as I can tell ghc does *not* handle 
sigfpe (googling "haskell sigfpe” turns up blog posts on Haskell by someone 
called “sigfpe”). I think it would be jolly useful to be able to get stack 
traces of floating point exceptions. How much work would this be? I’d be happy 
to have a go at it if someone could provide help and guidance.

There seems to have been some discussion of it on the ghc-devs mailing list in 
September 
(https://mail.haskell.org/pipermail/ghc-devs/2016-September/date.html) but not 
much in the way of write up.

Dominic Steinitz
domi...@steinitz.org
http://idontgetoutmuch.wordpress.com

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


Re: Stack traces in ghci

2016-12-07 Thread dominic
Hi Simon,

Thanks for getting back.

1. Without -prof and -fexternal-interpreter, the program runs fine.

2. With just -prof, the program runs fine.

3. With just -fexternal-interpreter, I get the error below.

Dominic.

> On 7 Dec 2016, at 13:52, Simon Marlow  wrote:
> 
> Hi Dominic - this looks like a problem with loading hmatrix into GHCi.  Does 
> it load without -prof and -fexternal-interpreter?  How about with just 
> -fexternal-interpreter?
> 
> Cheers
> SImon
> 
> On 5 December 2016 at 12:20, Dominic Steinitz  > wrote:
> I am trying to debug a package in which there is a divide by 0 error and 
> attempting to use Simon Marlow’s stack traces: 
> https://simonmar.github.io/posts/2016-02-12-Stack-traces-in-GHCi.html 
> . 
> However ghci is complaining about  missing symbols. What do I need to add to 
> the command line to coax ghci into giving me a stack trace?
> 
> > ~/Dropbox/Private/Stochastic/demo $ ghci -fexternal-interpreter -prof 
> > fe-handling-example.o -i../../monad-bayes/src  
> > -package-db=.cabal-sandbox/x86_64-osx-ghc-8.0.1-packages.conf.d
> > GHCi, version 8.0.1: http://www.haskell.org/ghc/ 
> >   :? for help
> > Prelude> :l app/Main.hs
> > [ 1 of 16] Compiling Control.Monad.Bayes.LogDomain ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/LogDomain.hs, interpreted )
> > [ 2 of 16] Compiling Control.Monad.Bayes.Primitive ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Primitive.hs, interpreted )
> > [ 3 of 16] Compiling Control.Monad.Bayes.Class ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Class.hs, interpreted )
> > [ 4 of 16] Compiling Control.Monad.Bayes.Sampler ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Sampler.hs, interpreted )
> > [ 5 of 16] Compiling Control.Monad.Bayes.Sequential ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Sequential.hs, interpreted )
> > [ 6 of 16] Compiling Control.Monad.Bayes.Prior ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Prior.hs, interpreted )
> > [ 7 of 16] Compiling Control.Monad.Bayes.Rejection ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Rejection.hs, interpreted )
> > [ 8 of 16] Compiling Control.Monad.Bayes.Weighted ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Weighted.hs, interpreted )
> > [ 9 of 16] Compiling Control.Monad.Bayes.Population ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Population.hs, interpreted )
> > [10 of 16] Compiling Control.Monad.Bayes.Deterministic ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Deterministic.hs, interpreted )
> > [11 of 16] Compiling Control.Monad.Bayes.Conditional ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Conditional.hs, interpreted )
> > [12 of 16] Compiling Control.Monad.Bayes.Dist ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Dist.hs, interpreted )
> > [13 of 16] Compiling Control.Monad.Bayes.Coprimitive ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Coprimitive.hs, interpreted )
> > [14 of 16] Compiling Control.Monad.Bayes.Trace ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Trace.hs, interpreted )
> > [15 of 16] Compiling Control.Monad.Bayes.Inference ( 
> > ../../monad-bayes/src/Control/Monad/Bayes/Inference.hs, interpreted )
> > [16 of 16] Compiling Main ( app/Main.hs, interpreted )
> >
> > app/Main.hs:92:7: warning: [-Wunused-matches]
> > Defined but not used: ‘a’
> >
> > app/Main.hs:92:9: warning: [-Wunused-matches]
> > Defined but not used: ‘prevP’
> >
> > app/Main.hs:92:15: warning: [-Wunused-matches]
> > Defined but not used: ‘prevZ’
> >
> > app/Main.hs:106:5: warning: [-Wunused-do-bind]
> > A do-notation statement discarded a result of type ‘GHC.Prim.Any’
> > Suppress this warning by saying
> >   ‘_ <- ($)
> >   error (++) "You are here " (++) show state (++) " " show 
> > p_obs’
> > Ok, modules loaded: Main, Control.Monad.Bayes.LogDomain, 
> > Control.Monad.Bayes.Primitive, Control.Monad.Bayes.Class, 
> > Control.Monad.Bayes.Population, Control.Monad.Bayes.Conditional, 
> > Control.Monad.Bayes.Inference, Control.Monad.Bayes.Sampler, 
> > Control.Monad.Bayes.Rejection, Control.Monad.Bayes.Weighted, 
> > Control.Monad.Bayes.Sequential, Control.Monad.Bayes.Trace, 
> > Control.Monad.Bayes.Dist, Control.Monad.Bayes.Prior, 
> > Control.Monad.Bayes.Deterministic, Control.Monad.Bayes.Coprimitive.
> > *Main> main
> > ghc-iserv-prof:
> > lookupSymbol failed in relocateSection (relocate external)
> > /Users/dom/Dropbox/Private/Stochastic/demo/.cabal-sandbox/lib/x86_64-osx-ghc-8.0.1/hmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ/libHShmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ_p.a:
> >  unknown symbol `___ieee_divdc3'
> > ghc-iserv-prof: Could not on-demand load symbol '_vectorScan'
> >
> > ghc-iserv-prof:
> > lookupSymbol failed in relocateSection (relocate external)
> > 

Re: Stack traces in ghci

2016-12-07 Thread Simon Marlow
Hi Dominic - this looks like a problem with loading hmatrix into GHCi.
Does it load without -prof and -fexternal-interpreter?  How about with just
-fexternal-interpreter?

Cheers
SImon

On 5 December 2016 at 12:20, Dominic Steinitz  wrote:

> I am trying to debug a package in which there is a divide by 0 error and
> attempting to use Simon Marlow’s stack traces: https://simonmar.github.io/
> posts/2016-02-12-Stack-traces-in-GHCi.html. However ghci is complaining
> about  missing symbols. What do I need to add to the command line to coax
> ghci into giving me a stack trace?
>
> > ~/Dropbox/Private/Stochastic/demo $ ghci -fexternal-interpreter -prof
> fe-handling-example.o -i../../monad-bayes/src  -package-db=.cabal-sandbox/
> x86_64-osx-ghc-8.0.1-packages.conf.d
> > GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
> > Prelude> :l app/Main.hs
> > [ 1 of 16] Compiling Control.Monad.Bayes.LogDomain (
> ../../monad-bayes/src/Control/Monad/Bayes/LogDomain.hs, interpreted )
> > [ 2 of 16] Compiling Control.Monad.Bayes.Primitive (
> ../../monad-bayes/src/Control/Monad/Bayes/Primitive.hs, interpreted )
> > [ 3 of 16] Compiling Control.Monad.Bayes.Class (
> ../../monad-bayes/src/Control/Monad/Bayes/Class.hs, interpreted )
> > [ 4 of 16] Compiling Control.Monad.Bayes.Sampler (
> ../../monad-bayes/src/Control/Monad/Bayes/Sampler.hs, interpreted )
> > [ 5 of 16] Compiling Control.Monad.Bayes.Sequential (
> ../../monad-bayes/src/Control/Monad/Bayes/Sequential.hs, interpreted )
> > [ 6 of 16] Compiling Control.Monad.Bayes.Prior (
> ../../monad-bayes/src/Control/Monad/Bayes/Prior.hs, interpreted )
> > [ 7 of 16] Compiling Control.Monad.Bayes.Rejection (
> ../../monad-bayes/src/Control/Monad/Bayes/Rejection.hs, interpreted )
> > [ 8 of 16] Compiling Control.Monad.Bayes.Weighted (
> ../../monad-bayes/src/Control/Monad/Bayes/Weighted.hs, interpreted )
> > [ 9 of 16] Compiling Control.Monad.Bayes.Population (
> ../../monad-bayes/src/Control/Monad/Bayes/Population.hs, interpreted )
> > [10 of 16] Compiling Control.Monad.Bayes.Deterministic (
> ../../monad-bayes/src/Control/Monad/Bayes/Deterministic.hs, interpreted )
> > [11 of 16] Compiling Control.Monad.Bayes.Conditional (
> ../../monad-bayes/src/Control/Monad/Bayes/Conditional.hs, interpreted )
> > [12 of 16] Compiling Control.Monad.Bayes.Dist (
> ../../monad-bayes/src/Control/Monad/Bayes/Dist.hs, interpreted )
> > [13 of 16] Compiling Control.Monad.Bayes.Coprimitive (
> ../../monad-bayes/src/Control/Monad/Bayes/Coprimitive.hs, interpreted )
> > [14 of 16] Compiling Control.Monad.Bayes.Trace (
> ../../monad-bayes/src/Control/Monad/Bayes/Trace.hs, interpreted )
> > [15 of 16] Compiling Control.Monad.Bayes.Inference (
> ../../monad-bayes/src/Control/Monad/Bayes/Inference.hs, interpreted )
> > [16 of 16] Compiling Main ( app/Main.hs, interpreted )
> >
> > app/Main.hs:92:7: warning: [-Wunused-matches]
> > Defined but not used: ‘a’
> >
> > app/Main.hs:92:9: warning: [-Wunused-matches]
> > Defined but not used: ‘prevP’
> >
> > app/Main.hs:92:15: warning: [-Wunused-matches]
> > Defined but not used: ‘prevZ’
> >
> > app/Main.hs:106:5: warning: [-Wunused-do-bind]
> > A do-notation statement discarded a result of type ‘GHC.Prim.Any’
> > Suppress this warning by saying
> >   ‘_ <- ($)
> >   error (++) "You are here " (++) show state (++) " " show
> p_obs’
> > Ok, modules loaded: Main, Control.Monad.Bayes.LogDomain,
> Control.Monad.Bayes.Primitive, Control.Monad.Bayes.Class,
> Control.Monad.Bayes.Population, Control.Monad.Bayes.Conditional,
> Control.Monad.Bayes.Inference, Control.Monad.Bayes.Sampler,
> Control.Monad.Bayes.Rejection, Control.Monad.Bayes.Weighted,
> Control.Monad.Bayes.Sequential, Control.Monad.Bayes.Trace,
> Control.Monad.Bayes.Dist, Control.Monad.Bayes.Prior, 
> Control.Monad.Bayes.Deterministic,
> Control.Monad.Bayes.Coprimitive.
> > *Main> main
> > ghc-iserv-prof:
> > lookupSymbol failed in relocateSection (relocate external)
> > /Users/dom/Dropbox/Private/Stochastic/demo/.cabal-
> sandbox/lib/x86_64-osx-ghc-8.0.1/hmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ/
> libHShmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ_p.a: unknown symbol
> `___ieee_divdc3'
> > ghc-iserv-prof: Could not on-demand load symbol '_vectorScan'
> >
> > ghc-iserv-prof:
> > lookupSymbol failed in relocateSection (relocate external)
> > /Users/dom/Dropbox/Private/Stochastic/demo/.cabal-
> sandbox/lib/x86_64-osx-ghc-8.0.1/hmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ/
> libHShmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ_p.a: unknown symbol
> `_vectorScan'
> > ghc-iserv-prof: Could not on-demand load symbol '_
> hmatrixzm0zi18zi0zi0zm7aYEqJARQEvKYNyM4UGAPZZ_InternalziVectorizzed_
> constantAux_closure'
> >
> > ghc-iserv-prof:
> > lookupSymbol failed in relocateSection (relocate external)
> > /Users/dom/Dropbox/Private/Stochastic/demo/.cabal-
> sandbox/lib/x86_64-osx-ghc-8.0.1/hmatrix-0.18.0.0-7aYEqJARQEvKYNyM4UGAPZ/
>