<div dir="ltr">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.<div><br></div><div>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:</div><div><br></div><div>* b44ae6e41bab47442d6fad8871d3f4e6e705aa40 to fix the crash.</div><div>* 2ac5b471a5d9a242a7591e8611d6d6385cbb2a89 to fix the build in c2hs<=0.18.0</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 6, 2015 at 6:49 PM, John Millikin <span dir="ltr"><<a href="mailto:jmillikin@gmail.com" target="_blank">jmillikin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I've verified the crash occurs when building with c2hs-0.25.2, and does not occur when building with c2hs-0.18.2.<div><br></div><div>The generated code for withGlyph in 0.18.2 is:</div><div><br></div><div><div>        (\(CCharT ptr) val -> do {pokeByteOff ptr 0 (val::CULong)}) (CCharT pBuf) cAttrs</div><div>        (\(CCharT ptr) val -> do {pokeByteOff ptr 8 (val::(CWString))}) (CCharT pBuf) (wordPtrToPtr (fromIntegral (ord char)))</div><div>        io (CCharT pBuf)</div></div><div><br></div><div>The generated code for withGlyph in 0.25.2 is:</div><div><br></div><div><div>        (\(CCharT ptr) val -> do {pokeByteOff ptr 0 (val :: CULong)}) (CCharT pBuf) cAttrs</div><div>        (\(CCharT ptr) val -> do {copyArray (ptr `plusPtr` 8) (val :: (CWString)) 5}) (CCharT pBuf) (wordPtrToPtr (fromIntegral (ord char)))</div><div>        io (CCharT pBuf)</div></div><div><br></div><div>The 0.25.2 code is definitely not going to work.</div><div><br></div><div>Looking through the c2hs changelog, there are a number of suspicious-sounding entries that could be related:</div><div><br></div><div>* [0.21.1] Fix treatment of arrays within structs [#115]</div><div>* [0.21.1] Add default marshallers for C types [#83]</div><div>* [0.22.1] Default marshallers for Char types [#98]</div><div>* [0.24.1] Arrays in structuress bug [#123]</div><div><br></div><div>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.</div><div><br></div><div>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.</div></div>
</blockquote></div><br></div>