
Hi I am writing a network server in haskell. Lately I seem to have introduced a new bug. On Linux, when a client closes the connection to the server, the server dumps core. On Windows, the error message there is way different from the core dump on Linux. It says: application.exe: config.xml: openFile: does not exist (No such file or directory) I use readFile to read the config file. I tried to print out the config file after it is read to make sure that it is completely read. I only load this config file exactly once during program initialization. The config is used long before the crash. I printed the current working dir in the exception handler and there is something interesting. Instead of the path to the application, it is "\C:\\WINDOWS\\system32". There are many things i do not understand. Why the different behaviour on Linux and Windows? Shouldn't an exception be thrown on Linux instead of a core dump? I don't use any unsafePerformIO or foreign calls. Why the changed path? I never change working directory in my code. Why is a function (-> reading the config file) re-evaluated at a later point in time? How can I debug such a problem? My environement is ghc 6.6 on Ubuntu or Windows XP. thanks for any ideas Stefan

On 1/8/07, Stefan Aeschbacher
There are many things i do not understand. Why the different behaviour on Linux and Windows? Shouldn't an exception be thrown on Linux instead of a core dump? I don't use any unsafePerformIO or foreign calls. Why the changed path? I never change working directory in my code. Why is a function (-> reading the config file) re-evaluated at a later point in time?
How can I debug such a problem?
My environement is ghc 6.6 on Ubuntu or Windows XP.
It may be difficult to say without seeing your code. Is it possible for you to post it, or at least a minimal test case that would illustrate the different errors on the different OSes? What Unix toolkit are you using when running ghc on Windows, if any (cygwin, mingw, both, neither?) Cheers, Kirsten -- Kirsten Chevalier* chevalier@alum.wellesley.edu *Often in error, never in doubt "What is research but a blind date with knowledge?" -- Will Henry

2007/1/8, Kirsten Chevalier
On 1/8/07, Stefan Aeschbacher
wrote: There are many things i do not understand. Why the different behaviour on Linux and Windows? Shouldn't an exception be thrown on Linux instead of a core dump? I don't use any unsafePerformIO or foreign calls. Why the changed path? I never change working directory in my code. Why is a function (-> reading the config file) re-evaluated at a later point in time?
How can I debug such a problem?
My environement is ghc 6.6 on Ubuntu or Windows XP.
It may be difficult to say without seeing your code. Is it possible for you to post it, or at least a minimal test case that would illustrate the different errors on the different OSes? What Unix toolkit are you using when running ghc on Windows, if any (cygwin, mingw, both, neither?)
I know that it's difficult without code but unfortunately the whole program is already quite large (several thousand lines) and I wouldn't see how to extract a relevant test case at the moment as i have no real clue where to search for the problem. I use cygwin on Windows. I just compiled the application from a cmd.exe and the result is the same (even though cmd.exe (and the normal cygwin terminal) swallows the error message, but the error is shown when run in rxvt). regards Stefan

Hi Stefan,
I am writing a network server in haskell. Lately I seem to have introduced a new bug. On Linux, when a client closes the connection to the server, the server dumps core.
Are you using any calls to system? Any libraries which may do funky stuff?
application.exe: config.xml: openFile: does not exist (No such file or directory)
I use readFile to read the config file. I tried to print out the config file after it is read to make sure that it is completely read. I only load this config file exactly once during program initialization. The config is used long before the crash. I printed the current working dir in the exception handler and there is something interesting. Instead of the path to the application, it is "\C:\\WINDOWS\\system32".
What is the working directory at the begining? Is that really the working directory? The "\C" at the start isn't the C drive, but some bizare escape code, I think. Thanks Neil

Hi
2007/1/8, Neil Mitchell
Hi Stefan,
I am writing a network server in haskell. Lately I seem to have introduced a new bug. On Linux, when a client closes the connection to the server, the server dumps core.
Are you using any calls to system? Any libraries which may do funky stuff? No calls to system. Libraries I use: MissingH (only some time function) and HaXML.
application.exe: config.xml: openFile: does not exist (No such file or directory)
I use readFile to read the config file. I tried to print out the config file after it is read to make sure that it is completely read. I only load this config file exactly once during program initialization. The config is used long before the crash. I printed the current working dir in the exception handler and there is something interesting. Instead of the path to the application, it is "\C:\\WINDOWS\\system32".
What is the working directory at the begining? Is that really the working directory? The "\C" at the start isn't the C drive, but some bizare escape code, I think. Oups, I think i must have slipped that first \ in by mistake during the composition of the mail. The path at the start of the application is d:\development\simulator_v2 and when the error occurs it is C:\WINDOWS\system32 (without the show i used before).
In the last hours I found out the following:
the program looks something like this:
main = do withSocketsDo $ runSimulator
runSimulator = do
dir <- getCurrentDirectory
putStrLn ("Dir is: " ++ dir)
config <- readConfig
fork many threads
It seems as if runSimulator is executed twice when the error happens.
The first time dir is printed correctly (d:...). Then the application
starts, all threads are created and it runs normally. When the client
closes the socket the error: "

Hi,
I finally found and solved the problem. The problem was in a small
library I wrote which handles threads. When a thread executed its
error handler, it started to kill (with throwTo) all other threads in
the group he belongs to. Unfortunately all other threads started their
error handlers too and started killing all other threads (again). The
resulting thunderstorm of throwTos lead to the strange behaviour I
observed.
regards
Stefan
2007/1/8, Stefan Aeschbacher
Hi
I am writing a network server in haskell. Lately I seem to have introduced a new bug. On Linux, when a client closes the connection to the server, the server dumps core. On Windows, the error message there is way different from the core dump on Linux. It says:
application.exe: config.xml: openFile: does not exist (No such file or directory)
I use readFile to read the config file. I tried to print out the config file after it is read to make sure that it is completely read. I only load this config file exactly once during program initialization. The config is used long before the crash. I printed the current working dir in the exception handler and there is something interesting. Instead of the path to the application, it is "\C:\\WINDOWS\\system32".
There are many things i do not understand. Why the different behaviour on Linux and Windows? Shouldn't an exception be thrown on Linux instead of a core dump? I don't use any unsafePerformIO or foreign calls. Why the changed path? I never change working directory in my code. Why is a function (-> reading the config file) re-evaluated at a later point in time?
How can I debug such a problem?
My environement is ghc 6.6 on Ubuntu or Windows XP.
thanks for any ideas
Stefan
participants (3)
-
Kirsten Chevalier
-
Neil Mitchell
-
Stefan Aeschbacher