[Haskell-beginners] "Segmentation fault/access violation" when working with FFI

Henk-Jan van Tuyl hjgtuyl at chello.nl
Sun Jan 5 07:50:49 UTC 2014

On Sat, 04 Jan 2014 01:45:38 +0100, Leza Morais Lutonda  
<leza.ml at fecrd.cujae.edu.cu> wrote:

> Hi,
> I has trying to use the portaudio [1] package to play some sound, and  
> running the examples [2] results in "Segmentation fault/access  
> violation" error.
> How can I solve this problem?

As far as I can tell, there is no good solution for this. You can try to  
get a stack trace[0][1], or, at Haskell level, find the location error  
with the GHCi debugger[2]

Check if you have the correct versions of dynamic libraries, if  
applicable. Note, that a missing dynamic library is not always reported  
properly; sometimes, GHCi mentions a missing dynamic library, while this  
is not reported when running a compiled program. For Windows, there are  
cygcheck and Dependency Walker to get an overview of the DLL dependencies.

Another problem, that might arise, is a changed calling convention; the  
Haskell binding to PortAudio uses ccall, the PortAudio C software might  
have recently adopted a different calling convention.

Henk-Jan van Tuyl

[0] http://spin.atomicobject.com/2013/01/13/exceptions-stack-traces-c/

Folding at home
What if you could share your unused computer power to help find a cure? In  
just 5 minutes you can join the world's biggest networked computer and get  
us closer sooner. Watch the video.

Haskell programming

More information about the Beginners mailing list