lambda-llama / bitset

A compact functional set data structure
http://hackage.haskell.org/package/bitset
MIT License
13 stars 13 forks source link

segfault with Data.BitSet.Dynamic #12

Open jwaldmann opened 10 years ago

jwaldmann commented 10 years ago

with ghc-7.6.3, bitset-1.4.7 (current from hackage), on x86_64 fedora, in ghci I get this:

import Data.BitSet.Dynamic
fromList [11,63]

Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package bitset-1.4.7 ... linking ... done.
fromList [3,7,8,10,11,14,15,17,20,21,22,25,28,29,30,33,37,40,41,42,43,44,45,46,63]
ghc: internal error: evacuate: strange closure type 1103044792
    (GHC version 7.6.3 for x86_64_unknown_linux)

import Data.BitSet.Dynamic
fromList [1,64]

Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package bitset-1.4.7 ... linking ... done.
fromList [3,5,8,9,13,15,18,19,20,36,37,38,39,40,41,42,43,44,45,46,64]
Segmentation fault (core dumped)

it seems to work ok with Data.BitSet.Generic; so it would depend on a difference between Integer and FasterInteger?

superbobry commented 10 years ago

Thanks for reporting this, but unfortunately I was unable to reproduce the bug on OS X, @knsd can you try a Linux machine?

jwaldmann commented 10 years ago

I was checking this on two other machines (all x86_64) and the behaviour seems to depend on libgmp version. It works fine with libgmp.so.3.5.2 (debian 6), libgmp.so.10.1.1 (fedora 19), but breaks (as reported above) with libgmp.so.10.1.2 (fedora 20). All of this with ghc-7.6.3 compiled from source.

superbobry commented 10 years ago

As far as I know GHC uses its own patched libgmp version. This also should be the version GHC links cbits/gmp-extras.cmm with, due to:

import "integer-gmp" __gmpz_init_set;
import "integer-gmp" __gmpz_popcount;
import "integer-gmp" __gmpz_tstbit;
import "integer-gmp" __gmpz_setbit;
import "integer-gmp" __gmpz_clrbit;

But since you have the issue with a specific system-wide libgmp version, I've tried reproducing it on the latest Ubuntu:

$ cat /etc/lsb-release                        
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu 13.10"
$ sudo aptitude show libgmp-dev | grep Version
Version: 2:5.1.2+dfsg-2ubuntu1

but everything worked as expected. Are you sure it's libgmp which causes the problem?