Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
trofi opened this issue Sep 25, 2015 · 3 comments

Comments

@trofi
Copy link

trofi commented Sep 25, 2015

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:

  • at least print out precise location of problematic expression in .i file so it would be clear what can't be parsed.
  • and ideally make it work :)

Thanks!

@ian-ross
Copy link
Member

@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
Copy link
Author

trofi commented Sep 25, 2015

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 :)

@trofi trofi closed this as completed Sep 25, 2015
@ian-ross
Copy link
Member

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants