-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault when using mysql on Windows #18
Comments
Finally, I've managed to get mysql to work. Maybe someone had similar trouble, so here's an explanation of what I did:
After that, the example from my previous comment should also compile and link fine, and running it shouldn't yield a segmenation fault anymore. Running the program from GHCi should also work. I'm aware that this is a terrible hack and some MySQL features may not work correctly (or at all), and there still is the risk of GHC's RTS interfering with the SQL connection requests. But for me the basic functions for sending requests and fetching data work fine, so I don't really care at the moment. Any comments or suggestions of a more sane way to build the package on Windows are welcome, of course. |
Thanks for documenting this. Are you building for 64-bit? |
No, I'm using an older 32-bit Windows XP system. |
I'm trying to use mysql-0.1.1.8 on a Windows system. I managed to circumvent #3 by passing the flags manually via
--extra-include/lib-dirs
to cabal. However, there are more problems because pthread is not supported on Windows systems. Using pthreads-win32 (http://www.sourceware.org/pthreads-win32/) still leads to errors because several definitions fromsignal.h
are not found in my MinGW installation.As all the pthread functions only seem to be used to avoid RTS interruptions, I removed
mysql_signals.h
andmysql_signals.c
from the project and changed the foreign import calls inDatabase.MySQL.Base.C
back to their original names, e.g.becomes
etc.
After doing these changes the package builds fine, the following test program builds fine and there aren't any linker errors anymore.
The only problem is the program produces a segmentation fault when run:
Note that the call to
clientInfo
works fine, but the attempt to connect to the database segfaults. I thought it might be an incompatible MySQL version of something like that, so I wrote a small C program doing basically the same function calls, and that works fine:outputs
Performing SQL requests and fetching the result also works fine in C. So the problem clearly is related to the Haskell package, but I have no idea where to start debugging this. May it be the changes I did to the package causing this problem? I would try using the functions from
Database.MySQL.Base.C
directly but I'm not familiar with the FFI, so I don't know how to use them safely.Any ideas on that?
The text was updated successfully, but these errors were encountered: