#3745: Non-deterministic behavior with FFI
---------------------------------+------------------------------------------
Reporter: gchrupala | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler (FFI)
Version: 6.10.4 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
---------------------------------+------------------------------------------
I have a simple perceptron learning algorithm in C++ which I am calling
from Haskell via FFI. Most of the time it works perfectly, but
occasionally the results it produces are not the expected. It seems to
happen more often if there is another memory/cpu intensive process running
on the machine.
The same never happens when I call the same function from C++, which seems
to indicate the problem is related to GHC.
I attach a simplified extract of the code which will show the problem.
I included:
* c_perceptronmodel.cpp, c_perceptronmodel.h : C++ implementation
* test.hs : Haskell program which calls the C++ function via FFI
* test.cpp : Equivalent C++ program which calls the same C++ function
* run.sh : shell script which will repeatedly run a program and check if
any consecutive two runs produce different results
* train : data file which the programs process
I compiled using GHC 6.10.4 like this:
{{{
ghc-6.10.4 --make -O2 -o test-ghc-6.10.4 test.hs c_perceptronmodel.cpp
-lstdc++
}}}
To see the problem execute:
{{{
./run.sh ./test-ghc-6.10.4
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3745>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs