Ticket #3066 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Crash with bogus FFI declaration

Reported by: simonpj Owned by: simonpj
Priority: high Milestone:
Component: Compiler Version: 6.10.1
Keywords: Cc: ben.franksen@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: ffi/should_fail/T3066 Blocked By:
Blocking: Related Tickets:

Description

Ben Franksen finds this:

{-# LANGUAGE ForeignFunctionInterface, RankNTypes #-}
import Foreign
type X u = Ptr ()
foreign import ccall bla :: (forall u. X u) -> IO ()

I know of course that I must not use fancy types in foreign imports. I forgot for a moment and instead of an error message got:

ben@sarun> ghci Bug3
GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( Bug3.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 6.10.1 for i386-unknown-linux):
        unboxArg:
    Bug3.hs:4:0-51 forall u{tv aht} [tv].
                   main:Main.X{tc rhp} u{tv aht} [tv]

Change History

Changed 4 years ago by simonpj

  • cc ben.franksen@… added

Changed 4 years ago by simonpj

  • owner changed from simonpj to igloo
  • priority changed from normal to high
  • type changed from bug to merge
  • testcase set to ffi/should_fail/T3066

Thanks for reporting this. Fixed by

Tue Mar  3 17:42:58 GMT 2009  simonpj@microsoft.com
  * Fix Trac #3066: checking argument types in foreign calls
  
  When checking argument types in a foreign call we were stupidly
  looking through foralls.  The fix is easy.

Please merge to the 6.10 branch.

Simon

Changed 4 years ago by igloo

  • owner changed from igloo to simonpj
  • type changed from merge to bug

This breaks the build:

/home/ian/ghc/darcs/ghc/ghc/stage1-inplace/ghc -package-name base-4.0.0.0 -hide-all-packages -no-user-package-conf -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -Iinclude -optP-include -optPdist/build/autogen/cabal_macros.h -#include "HsBase.h" -odir dist/build -hidir dist/build -stubdir dist/build -package ghc-prim-0.1.0.0 -package integer-0.1.0.0 -package rts-1.0 -O -package-name base -XMagicHash -XExistentialQuantification -XRank2Types -XScopedTypeVariables -XUnboxedTuples -XForeignFunctionInterface -XUnliftedFFITypes -XDeriveDataTypeable -XGeneralizedNewtypeDeriving -XFlexibleInstances -XStandaloneDeriving -XPatternGuards -XEmptyDataDecls -XNoImplicitPrelude -XCPP -idist/build  -Werror -H64m -O0 -fasm -O -fasm -dcore-lint -Wall -fno-warn-deprecated-flags -c Foreign/Marshal/Alloc.hs -o dist/build/Foreign/Marshal/Alloc.o  -ohi dist/build/Foreign/Marshal/Alloc.hi

Foreign/Marshal/Alloc.hs:201:0:
    Unacceptable type in foreign declaration: forall a. FinalizerPtr a
    When checking declaration:
        foreign import ccall unsafe "static stdlib.h &free" finalizerFree
          :: FinalizerPtr a
make[2]: *** [dist/build/Foreign/Marshal/Alloc.o] Error 1

Changed 4 years ago by simonpj

  • owner changed from simonpj to igloo
  • type changed from bug to merge

Sorry, my fault. My fix exposed a second bug which has been there for ages. Fixed by

Wed Mar  4 09:19:13 GMT 2009  simonpj@microsoft.com
  * Fix a long-standing latent bug (and the build): check res_ty not sig_ty

Pls merge

Simon

Changed 4 years ago by igloo

  • owner changed from igloo to simonpj
  • type changed from merge to bug

These patches make haddock apparently go into an infinite loop (when haddocking the unix package). I'm not sure if this is a bug in haddock or GHC. Do you know what's going on?

With this Q.hs:

module Q () where

newtype Foo = Foo Foo
$ /home/ian/ghc/6.10-branch/ghc/utils/haddock/install-inplace/bin/haddock --html -B/home/ian/ghc/6.10-branch/ghc/inplace-datadir Q --optghc=-v
Using package config file: /home/ian/ghc/6.10-branch/ghc/inplace-datadir/../inplace-datadir/package.conf
hiding package base-3.0.3.0 to avoid conflict with later version base-4.0.0.0
wired-in package ghc-prim mapped to ghc-prim-0.1.0.0
wired-in package integer mapped to integer-0.1.0.0
wired-in package base mapped to base-4.0.0.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1.0
wired-in package syb mapped to syb-0.1.0.0
wired-in package template-haskell mapped to template-haskell-2.3.0.0
wired-in package dph-seq[""] not found.
wired-in package dph-par[""] not found.
*** Chasing dependencies:
Chasing modules from: *Q.hs
*** Parser:
*** Renamer/typechecker:
*** Tidy [hoot] type env:
compile: input file Q.hs
*** Tidy [hoot] type env:

Changed 4 years ago by igloo

ghci also seems to go into an infinite loop on Q.hs.

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Both merged, as well as

Thu Mar  5 01:09:35 PST 2009  simonpj@microsoft.com                             
  * Finally fix Trac #3066                                                      
  Ignore-this: 8734c1799f854d9da6be76a9c134335e                                 
                                                                                
  This is a fix to                                                              
    Tue Mar  3 17:42:58 GMT 2009  simonpj@microsoft.com                         
      * Fix Trac #3066: checking argument types in foreign calls                
  which I embarassingly got wrong.                                              
                                                                                
  Have to be careful when expanding recursive newtypes.                         
                                                                                
  Pls merge.                                                                    

Oh, the perils of putting "The fix is easy." in a commit message! :-)

Note: See TracTickets for help on using tickets.