SourceForge.net | 1 Aug 2004 23:55
Picon
Favicon

[ ghc-Bugs-997511 ] Options -no-hs-main -debug cause 'impossible' to happen

Bugs item #997511, was opened at 2004-07-25 05:38
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=997511&group_id=8032

Category: Compiler (FFI)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Options -no-hs-main -debug cause 'impossible' to happen

Initial Comment:
Here's the command line:

ghc -c ForeignTest.hs -fglasgow-exts -package text
-no-hs-main

And here's the module:
-----------------------
module ForeignTest (reduce) where

import Foreign.StablePtr
import GensDef
import GensCoreIO

foreign export ccall "reduce"
   reduceMain ::
(Continue reading)

SourceForge.net | 2 Aug 2004 17:23
Picon
Favicon

[ ghc-Bugs-997511 ] Options -no-hs-main -debug cause 'impossible' to happen

Bugs item #997511, was opened at 2004-07-25 05:38
Message generated for change (Comment added) made by nobody
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=997511&group_id=8032

Category: Compiler (FFI)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Options -no-hs-main -debug cause 'impossible' to happen

Initial Comment:
Here's the command line:

ghc -c ForeignTest.hs -fglasgow-exts -package text
-no-hs-main

And here's the module:
-----------------------
module ForeignTest (reduce) where

import Foreign.StablePtr
import GensDef
import GensCoreIO

foreign export ccall "reduce"
   reduceMain ::
(Continue reading)

SourceForge.net | 2 Aug 2004 20:08
Picon
Favicon

[ ghc-Bugs-1002139 ] Assertion failed in GC.c

Bugs item #1002139, was opened at 2004-08-02 14:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1002139&group_id=8032

Category: Runtime System
Group: 6.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Mario Blažević (blamario)
Assigned to: Nobody/Anonymous (nobody)
Summary: Assertion failed in GC.c

Initial Comment:
Instructions:

1. Download the attached archive.
2. tar xzf gens.tar.gz
3. cd gens
4. make
5. make Env/If.so
6. ./gens - <tests

The message I'm getting is:

ASSERTION FAILED: file GC.c, line 1722

When I compile without -debug option, there's a
segfault with no error report. If I do +RTS -G1 -RTS,
(Continue reading)

SourceForge.net | 2 Aug 2004 21:49
Picon
Favicon

[ ghc-Bugs-1002139 ] Assertion failed in GC.c

Bugs item #1002139, was opened at 2004-08-02 14:08
Message generated for change (Comment added) made by blamario
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1002139&group_id=8032

Category: Runtime System
Group: 6.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Mario Blaževi&#263; (blamario)
Assigned to: Nobody/Anonymous (nobody)
Summary: Assertion failed in GC.c

Initial Comment:
Instructions:

1. Download the attached archive.
2. tar xzf gens.tar.gz
3. cd gens
4. make
5. make Env/If.so
6. ./gens - <tests

The message I'm getting is:

ASSERTION FAILED: file GC.c, line 1722

When I compile without -debug option, there's a
segfault with no error report. If I do +RTS -G1 -RTS,
(Continue reading)

Volodimir Rudenko | 4 Aug 2004 17:49
Picon

Return signatures in case expressions

Hello,

I have read 'Lexically-scoped type variables' by Simon Peyton Jones and
Mark Shields. When discussing result signatures, authors mensioned in
Section 4.1.2. 'Result signatures':

        "Result signatures can be used on lambda abstractions and
        case expressions, as well as function definitions." ,

but they did not give syntax definitions for those additional cases.

The syntax for lambdas is not hard to guess, but not so for cases.
So, I browsed GHC documentation and found one example of using a result
signature in a case expression (Section 7.4. 'Type system extensions',
Subsection 7.4.10.3 'Where a pattern type signature can occur'):

        "Pattern type signatures, including the result part, can be
        used in case expressions:
                case e of { (x::a, y) :: a -> x } ".

On the other hand, Subsection 7.4.10.4. 'Result type signatures' does not
mention 'the case of case expressions' (sorry for pun).

I have tried the above example with GHC 6.2.1 and CVS GHC. Both rejected it:

        Prelude> :set -fglasgow-exts
        Prelude> case e of { (x::a, y) :: a -> x }
        <interactive>:1: parse error on input `}'
        Prelude>

(Continue reading)

Duncan Coutts | 7 Aug 2004 19:52
Picon
Picon

-fvia-c -O generates mal-typed C code (casts double via unsigned int)

Hi,

Sorry this is a rather complicated bug report but I think I've tracked
it down, please bear with me. :-)

It involves C code, FFI and optimisations (all seem to be required).
Nice.

The problem shows up as a double value loosing precision when it is sent
to C land and back. It's because ghc generates C code that casts the
value via an unsigned word when it gets it back from C land.

Attached is a small collection of modules which exhibit the problem. If
I make the test case much smaller, the problem goes away. It's not too
complicated code though. Some imports were hacked around and a few bits
commented out to get it out of a larger library. The test program sends
(-1) :: Double to C land and back and gets something rather different
back.

For some context, it's part of the gtk2hs bindings. It deals with a data
type (GValue) on the C side that is a 'variant' type. A big union of
primitive types with an enum field to say what is in the union. The code
implements peek/poke for this type. The peek/poke code does the obvious
thing which is a case expression on the Haskell sum-type value or the
type field of the C value. In each branch of the case we make an FFI
call to do the actual getting / setting:

peek gvPtr  = do
    gtype <- liftM (toEnum.fromIntegral::Word32 -> TMType) $
             (\hsc_ptr -> peekByteOff hsc_ptr 0) gvPtr
(Continue reading)

Duncan Coutts | 7 Aug 2004 19:59
Picon
Picon

Re: -fvia-c -O generates mal-typed C code (casts double via unsigned int)

On Sat, 2004-08-07 at 18:52, Duncan Coutts wrote:
> Attached is a small collection of modules which exhibit the problem.
> If I make the test case much smaller, the problem goes away. It's not
> too complicated code though. Some imports were hacked around and a few
> bits commented out to get it out of a larger library. The test program
> sends (-1) :: Double to C land and back and gets something rather
> different back.

Sorry, should have said:

This is with ghc 6.2.1, same problem with my 6.3 cvs from about a month
ago.

If you want to run this program you need to link with a few things:

ghc -ffi -O --make Test.hs -o test '-#include <glib-object.h>'
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgobject-2.0
-lglib-2.0

This is on Linux with glib-2.0 installed (it's part of gtk/gnome).

Duncan
SourceForge.net | 9 Aug 2004 12:41
Picon
Favicon

[ ghc-Bugs-997511 ] Options -no-hs-main -debug cause 'impossible' to happen

Bugs item #997511, was opened at 2004-07-25 12:38
Message generated for change (Comment added) made by simonmar
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=997511&group_id=8032

Category: Compiler (FFI)
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Options -no-hs-main -debug cause 'impossible' to happen

Initial Comment:
Here's the command line:

ghc -c ForeignTest.hs -fglasgow-exts -package text
-no-hs-main

And here's the module:
-----------------------
module ForeignTest (reduce) where

import Foreign.StablePtr
import GensDef
import GensCoreIO

foreign export ccall "reduce"
   reduceMain ::
(Continue reading)

Simon Marlow | 9 Aug 2004 14:33
Picon
Favicon

RE: Return signatures in case expressions

On 04 August 2004 16:50, Volodimir Rudenko wrote:

>         "Pattern type signatures, including the result part, can be
>         used in case expressions:
>                 case e of { (x::a, y) :: a -> x } ".
> 
> On the other hand, Subsection 7.4.10.4. 'Result type signatures' does
> not mention 'the case of case expressions' (sorry for pun).

That example isn't quite right.  Extra parentheses are needed:

  case e of { ((x::a, y) :: a) -> x } 

I've fixed the docs.

Cheers,
	Simon
Simon Marlow | 9 Aug 2004 15:23
Picon
Favicon

RE: -fvia-c -O generates mal-typed C code (casts double via unsignedint)

On 07 August 2004 18:53, Duncan Coutts wrote:

> The problem shows up as a double value loosing precision when it is
> sent 
> to C land and back. It's because ghc generates C code that casts the
> value via an unsigned word when it gets it back from C land.
[ bug report snipped ]

Thanks for an excellent report.  I knew what the bug was without trying
out the code.

Unfortunately, it's not easily fixed.  There's a part of the code
generator that needs to get hold of some unique temporaries, and there
isn't a supply of uniques to hand, so it always picks the same ones.

This bug is already fixed in the new backend (which will be 6.4).

I've committed a partial workaround for the bug to the HEAD, and will
merge it into 6.2.2.  The workaround fixes your program, but it will
fail if you use 'safe' (instead of 'unsafe') ccalls.  Fortunately, it
also improves performance :-)

Cheers,
	Simon

Gmane