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

Regards,
Henk-Jan van Tuyl


[0] http://spin.atomicobject.com/2013/01/13/exceptions-stack-traces-c/
[1]  
https://gist.github.com/jvranish/4441299/raw/a15d0d5a6c716f4f375ed5ea492b45350eaa6288/stack_traces.c
[2]  
http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html


-- 
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.
http://folding.stanford.edu/


http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--


More information about the Beginners mailing list