I've uploaded version 0.2.12 to Hackage and my site with a fix for this crash. It replaces the c2hs-based setters with a plain call to a C function, which handles the struct initialization.
Version 0.2.12 also has unrelated changes to add new functionality. If you'd prefer to cherrypick the fixes for this bug, they are: * b44ae6e41bab47442d6fad8871d3f4e6e705aa40 to fix the crash. * 2ac5b471a5d9a242a7591e8611d6d6385cbb2a89 to fix the build in c2hs<=0.18.0 On Sat, Jun 6, 2015 at 6:49 PM, John Millikin <[email protected]> wrote: > I've verified the crash occurs when building with c2hs-0.25.2, and does > not occur when building with c2hs-0.18.2. > > The generated code for withGlyph in 0.18.2 is: > > (\(CCharT ptr) val -> do {pokeByteOff ptr 0 (val::CULong)}) > (CCharT pBuf) cAttrs > (\(CCharT ptr) val -> do {pokeByteOff ptr 8 (val::(CWString))}) > (CCharT pBuf) (wordPtrToPtr (fromIntegral (ord char))) > io (CCharT pBuf) > > The generated code for withGlyph in 0.25.2 is: > > (\(CCharT ptr) val -> do {pokeByteOff ptr 0 (val :: CULong)}) > (CCharT pBuf) cAttrs > (\(CCharT ptr) val -> do {copyArray (ptr `plusPtr` 8) (val :: > (CWString)) 5}) (CCharT pBuf) (wordPtrToPtr (fromIntegral (ord char))) > io (CCharT pBuf) > > The 0.25.2 code is definitely not going to work. > > Looking through the c2hs changelog, there are a number of > suspicious-sounding entries that could be related: > > * [0.21.1] Fix treatment of arrays within structs [#115] > * [0.21.1] Add default marshallers for C types [#83] > * [0.22.1] Default marshallers for Char types [#98] > * [0.24.1] Arrays in structuress bug [#123] > > My recommendation is to revert to an older c2hs version, because any > package that uses c2hs to set the contents of an array is likely to be > silently broken right now. > > Some time in the next few days, I will build a bunch of c2hs binaries and > run that crash test to see which version in particular needs to be ifdef'd > in haskell-ncurses. >

