haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
198 stars 50 forks source link

c2hs crashes on '__builtin_offsetof': gtk2hsC2hs: c2hs/c/CNames.hs:(162,1)-(180,71): Non-exhaustive patterns in function naCExpr #150

Closed trofi closed 8 years ago

trofi commented 8 years ago

Reproducer:

  // cat a.h
  struct a { char c1, c2; };
  struct s {
    char par[__builtin_offsetof(struct a, c2)];
    char c;
  };

  // cat A.chs 
  module A where

  $ gtk2hsC2hs --precomp=a.bin --output=a.hs a.h A.chs
  gtk2hsC2hs: c2hs/c/CNames.hs:(162,1)-(180,71): Non-exhaustive patterns in function naCExpr

  $ gcc -c a.h # builds fine

The original issue is rather weird, it's a dev-haskell/glib build failure on ia64: https://bugs.gentoo.org/show_bug.cgi?id=498638#c18 Don't understand why original issue is specific only for ia64. Looks quite generic.

But this reproduces crashes fine on amd64 :)

The request:

Thanks!

ian-ross commented 8 years ago

@trofi Oh dear. I'll have to take a look at what the current status of gtk2hsC2hs is, but there was a schism between the gtk2hs tools and the main C2HS branch years ago, before I even got involved in maintaining C2HS. I'll have a look, but I think you might be out of luck there. gtk2hsC2hs is part of gtk2hs-buildtools: http://hackage.haskell.org/package/gtk2hs-buildtools

A quick check with the "real" C2HS seems to indicate that this might have been fixed at some point, but the fix never made it into the gtk2hs tools.

trofi commented 8 years ago

Ah, sorry! c2hs is indeed prints a better error message.

Don't understand why original issue is specific only for ia64 Another mystery is resolved: the original ucontext.h is platform-secific. Most of other platforms don't use offseof, thus no bug.

It's hard to imagine sane offsetof implementation, thus i'll close the bug.

My apologies :)

ian-ross commented 8 years ago

Don't worry! I think it took me some months after I started doing maintenance on C2HS to even realise that the gtk2hs version was a completely different beast...