"Segmentation fault/access violation" when working with FFI

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? Thanks. [1] http://hackage.haskell.org/package/portaudio [2] https://github.com/sw17ch/portaudio/blob/master/examples/Example1.h

On Sat, 04 Jan 2014 01:45:38 +0100, Leza Morais Lutonda
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/a15d0d5a6c716f4f375ed5ea492b453... [2] http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html -- Folding@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 --

El 1/4/2014 23:50, Henk-Jan van Tuyl escribió:
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
Thanks for the answer. Fortunately I could solve the problem (infortunately without knowing exactly what was causing it). I guess there is a bug in Sound.PortAudio module that causes the problem. What I did is to work directly with the bindings functions to the C Api in module Sound.PortAudio.Base and make my own `play` function (maybe some day publishing a package for easily playing and recording sound). -- Leza Morais Lutonda https://github.com/lemol
participants (2)
-
Henk-Jan van Tuyl
-
Leza Morais Lutonda