segfault depending on code position in source file

my code is structured like this , in summary: -- this function will return th N°BD from Sidonie for a given name -- note: names have been standardized between Sidonie and WDS getAlphaDelta :: Connection -> String -> IO (Double,Double) getAlphaDelta conn name = do let qry_head_AlphaDelta_AngularDistance = "select alpha,delta from AngularDistance where Nom = ?" :: Query (alpha_delta_rows :: [(Double,Double)]) <- query conn qry_head_AlphaDelta_AngularDistance (Only (name::String)) -- putStrLn $ show alpha_delta_rows return (head alpha_delta_rows) main = do conn <- connect defaultConnectInfo { connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie" } -- check getAlphaDelta works: let name3 = "A 7" putStrLn $ show name3 ad3 <- getAlphaDelta conn name3 putStr "ad3 =" putStrLn $ show ad3 this works i got result such as: "A 7" ad3 =(11297.0,-619.0) if i move the 5 lines of code at the end of file it segfault between the begin and end i have some DB connection and queriung , filtering, mapping... any idea? should i really upgrade the version of GHCI? Damien

Damien,
It is really hard to tell anything without the ability to reproduce the
problem on other systems. Try to come up with some example which is easy to
get running AND segfaulting on other computers, so that we could play with
it. Maybe post the minimal code in separate github repo and provide the
link.
--
Best, Artem
On Thu, 21 Feb 2019 at 10:14 Damien Mattei
my code is structured like this , in summary:
-- this function will return th N°BD from Sidonie for a given name -- note: names have been standardized between Sidonie and WDS getAlphaDelta :: Connection -> String -> IO (Double,Double) getAlphaDelta conn name = do let qry_head_AlphaDelta_AngularDistance = "select alpha,delta from AngularDistance where Nom = ?" :: Query (alpha_delta_rows :: [(Double,Double)]) <- query conn qry_head_AlphaDelta_AngularDistance (Only (name::String)) -- putStrLn $ show alpha_delta_rows return (head alpha_delta_rows)
main =
do conn <- connect defaultConnectInfo { connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie" }
-- check getAlphaDelta works:
let name3 = "A 7" putStrLn $ show name3 ad3 <- getAlphaDelta conn name3 putStr "ad3 =" putStrLn $ show ad3
this works i got result such as: "A 7" ad3 =(11297.0,-619.0)
if i move the 5 lines of code at the end of file it segfault
between the begin and end i have some DB connection and queriung , filtering, mapping...
any idea?
should i really upgrade the version of GHCI?
Damien _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

i had attached the whole file, so anyone can read the whole code, perheaps
it could help, saying me if there is compilation error on other ghc
versions, with mine no error at compilation.
The problem to test is that without the database connection which is behind
a firewall of course ,the code can not be executed.
Me i have no more idea, i will install tomorrow an earlier version of ghc
and continue to test.... if it's really a problem i could output the
partial result and continue in another language such as Racket or Python...
but i'm not at this point and hope to continue with Haskell...
Damien
On Thu, Feb 21, 2019 at 5:35 PM Artem Pelenitsyn
Damien,
It is really hard to tell anything without the ability to reproduce the problem on other systems. Try to come up with some example which is easy to get running AND segfaulting on other computers, so that we could play with it. Maybe post the minimal code in separate github repo and provide the link.
-- Best, Artem
On Thu, 21 Feb 2019 at 10:14 Damien Mattei
wrote: my code is structured like this , in summary:
-- this function will return th N°BD from Sidonie for a given name -- note: names have been standardized between Sidonie and WDS getAlphaDelta :: Connection -> String -> IO (Double,Double) getAlphaDelta conn name = do let qry_head_AlphaDelta_AngularDistance = "select alpha,delta from AngularDistance where Nom = ?" :: Query (alpha_delta_rows :: [(Double,Double)]) <- query conn qry_head_AlphaDelta_AngularDistance (Only (name::String)) -- putStrLn $ show alpha_delta_rows return (head alpha_delta_rows)
main =
do conn <- connect defaultConnectInfo { connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie" }
-- check getAlphaDelta works:
let name3 = "A 7" putStrLn $ show name3 ad3 <- getAlphaDelta conn name3 putStr "ad3 =" putStrLn $ show ad3
this works i got result such as: "A 7" ad3 =(11297.0,-619.0)
if i move the 5 lines of code at the end of file it segfault
between the begin and end i have some DB connection and queriung , filtering, mapping...
any idea?
should i really upgrade the version of GHCI?
Damien _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Am Do., 21. Feb. 2019 um 19:22 Uhr schrieb Damien Mattei < damien.mattei@gmail.com>:
i had attached the whole file, so anyone can read the whole code, perheaps it could help, saying me if there is compilation error on other ghc versions, with mine no error at compilation.
I very much doubt that anyone likes to read >500 lines of Haskell code with lots of external dependencies to help you with your problem. A good hint for Open Source SW in general: If you think you might have found a bug, cut down your example as much as possible, throw out as many external dependencies as you can while still reproducing your problem, then, and only then, post it to other people. You simply can't expect that other people will do that debugging work for you in their spare time. The code you post doesn't really have to make sense, it should just be the minimum amount of code needed to reproduce the problem. In a nutshell: The probability that you get some help is inversely proportional to the size of your example, and even more inversely proportional to the number of external dependencies (libraries etc.).
The problem to test is that without the database connection which is behind a firewall of course ,the code can not be executed. [...]
Well, that is basically a show stopper for getting help... I don't want to be mean, quite the opposite: I just want to explain why you probably won't receive any help in the current form. This is not special to the Haskell community, the situation would be very much the same if you posted an equivalent problem of similar size to the Racket/Python/... community. I'm quite sure that most maintainer would be happy to have a look e.g. at a program consisting of a dozen lines without external dependencies.

well i understand the difficulty, i just pos because ,really some times i
get incredible help that i coulmdn not even think it possible.
i admit the code is and the database connection is a stop help.
for the database i cannot do ,for the code i commented a lot and i can
resume with this concise code that recreate the problem:
it's quite simple i noticed that after one lines (see in code the lines and
the upper case comments) the query to DB in getAlphaDelta does not works
anymore (as it worked before ) but other functions making queries works
that what is strange...
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
import Database.MySQL.Simple
import Database.MySQL.Simple.QueryResults
import Database.MySQL.Simple.Result
import Database.MySQL.Simple.QueryParams
import Database.MySQL.Simple.Param
import Control.Monad
import qualified Data.Text as Tx
import Debug.Trace
import Data.Maybe as Maybe
import Text.Read
import Data.Tuple.Extra
getAlphaDelta :: Connection -> String -> IO (Double,Double)
getAlphaDelta conn name = do
let qry_head_AlphaDelta_AngularDistance = "select alpha,delta
from AngularDistance where Nom = ?" :: Query
(alpha_delta_rows :: [(Double,Double)]) <- query conn
qry_head_AlphaDelta_AngularDistance (Only (name::String))
return (head alpha_delta_rows)
main :: IO ()
main =
do
conn <- connect defaultConnectInfo
{ connectHost = "moita",
connectUser = "mattei",
connectPassword = "sidonie2",
connectDatabase = "sidonie" }
-- check getAlphaDelta works:
-- HERE getAlphaDelta WORKS
let name = "WOR 7"
putStrLn $ show name
ad <- getAlphaDelta conn name
putStr "ad ="
putStrLn $ show ad
(names ::[Only Tx.Text])<- query_ conn "SELECT Nom FROM AngularDistance
WHERE distance > 0.000278"
-- AFTER THE PREVIOUS LINE getAlphaDelta WILL NOT WORKS AND ISSUE A
SEGFAULT IN GHCI
let name3 = "A 7"
putStrLn $ show name3
ad3 <- getAlphaDelta conn name3
putStr "ad3 ="
putStrLn $ show ad3
close conn
here is the output:
[mattei@localhost Haskell]$ ghci
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Prelude> :load UpdateSidonie.hs
[1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted )
Ok, one module loaded.
*Main> main
"WOR 7"
ad =(17386.0,7120.0)
"A 7"
Segmentation fault (core dumped)
as you see the first call to getAlphaDelta is ok but the second issue a
Segmentation fault.
i will try now with ghci 8.4 .... and hiope to give you some news...
Damien
On Thu, Feb 21, 2019 at 8:15 PM Sven Panne
Am Do., 21. Feb. 2019 um 19:22 Uhr schrieb Damien Mattei < damien.mattei@gmail.com>:
i had attached the whole file, so anyone can read the whole code, perheaps it could help, saying me if there is compilation error on other ghc versions, with mine no error at compilation.
I very much doubt that anyone likes to read >500 lines of Haskell code with lots of external dependencies to help you with your problem. A good hint for Open Source SW in general: If you think you might have found a bug, cut down your example as much as possible, throw out as many external dependencies as you can while still reproducing your problem, then, and only then, post it to other people. You simply can't expect that other people will do that debugging work for you in their spare time. The code you post doesn't really have to make sense, it should just be the minimum amount of code needed to reproduce the problem.
In a nutshell: The probability that you get some help is inversely proportional to the size of your example, and even more inversely proportional to the number of external dependencies (libraries etc.).
The problem to test is that without the database connection which is behind a firewall of course ,the code can not be executed. [...]
Well, that is basically a show stopper for getting help...
I don't want to be mean, quite the opposite: I just want to explain why you probably won't receive any help in the current form. This is not special to the Haskell community, the situation would be very much the same if you posted an equivalent problem of similar size to the Racket/Python/... community. I'm quite sure that most maintainer would be happy to have a look e.g. at a program consisting of a dozen lines without external dependencies.

well , good news :-)
i tested the same code on a 64 bits Linux Centos 7.2 with GHC 8.4 and it
works fine...
so the problem is only under 32bits Linux Fedora Core 29 with GHC 8.2
we had a system failure or security issue last month and i had to upgrade
the 32 bit CPU 3 weeks ago to latest Linux Fedora Core version
but this had the side effect to downgrade the Haskell GHC compiler to 8.2
version
and the 8.2 version or 32 bit platform have bugs
if i can i will try to test with the 8.4 GHC on the 32 bit platform to see
if the problem was with 32bit vs 64bit; possible difference with Fedora and
CentOS also, but i think it's the 8.2 compiler that cause the bug...
regards,
damien
On Fri, Feb 22, 2019 at 10:55 AM Damien Mattei
well i understand the difficulty, i just pos because ,really some times i get incredible help that i coulmdn not even think it possible. i admit the code is and the database connection is a stop help. for the database i cannot do ,for the code i commented a lot and i can resume with this concise code that recreate the problem:
it's quite simple i noticed that after one lines (see in code the lines and the upper case comments) the query to DB in getAlphaDelta does not works anymore (as it worked before ) but other functions making queries works that what is strange...
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} import Database.MySQL.Simple import Database.MySQL.Simple.QueryResults import Database.MySQL.Simple.Result
import Database.MySQL.Simple.QueryParams import Database.MySQL.Simple.Param
import Control.Monad import qualified Data.Text as Tx import Debug.Trace import Data.Maybe as Maybe import Text.Read import Data.Tuple.Extra
getAlphaDelta :: Connection -> String -> IO (Double,Double) getAlphaDelta conn name = do let qry_head_AlphaDelta_AngularDistance = "select alpha,delta from AngularDistance where Nom = ?" :: Query (alpha_delta_rows :: [(Double,Double)]) <- query conn qry_head_AlphaDelta_AngularDistance (Only (name::String)) return (head alpha_delta_rows)
main :: IO ()
main =
do conn <- connect defaultConnectInfo { connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie" }
-- check getAlphaDelta works: -- HERE getAlphaDelta WORKS let name = "WOR 7" putStrLn $ show name ad <- getAlphaDelta conn name putStr "ad =" putStrLn $ show ad
(names ::[Only Tx.Text])<- query_ conn "SELECT Nom FROM AngularDistance WHERE distance > 0.000278"
-- AFTER THE PREVIOUS LINE getAlphaDelta WILL NOT WORKS AND ISSUE A SEGFAULT IN GHCI let name3 = "A 7" putStrLn $ show name3 ad3 <- getAlphaDelta conn name3 putStr "ad3 =" putStrLn $ show ad3
close conn
here is the output:
[mattei@localhost Haskell]$ ghci GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help Prelude> :load UpdateSidonie.hs [1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted ) Ok, one module loaded. *Main> main "WOR 7" ad =(17386.0,7120.0) "A 7" Segmentation fault (core dumped)
as you see the first call to getAlphaDelta is ok but the second issue a Segmentation fault.
i will try now with ghci 8.4 .... and hiope to give you some news...
Damien
On Thu, Feb 21, 2019 at 8:15 PM Sven Panne
wrote: Am Do., 21. Feb. 2019 um 19:22 Uhr schrieb Damien Mattei < damien.mattei@gmail.com>:
i had attached the whole file, so anyone can read the whole code, perheaps it could help, saying me if there is compilation error on other ghc versions, with mine no error at compilation.
I very much doubt that anyone likes to read >500 lines of Haskell code with lots of external dependencies to help you with your problem. A good hint for Open Source SW in general: If you think you might have found a bug, cut down your example as much as possible, throw out as many external dependencies as you can while still reproducing your problem, then, and only then, post it to other people. You simply can't expect that other people will do that debugging work for you in their spare time. The code you post doesn't really have to make sense, it should just be the minimum amount of code needed to reproduce the problem.
In a nutshell: The probability that you get some help is inversely proportional to the size of your example, and even more inversely proportional to the number of external dependencies (libraries etc.).
The problem to test is that without the database connection which is behind a firewall of course ,the code can not be executed. [...]
Well, that is basically a show stopper for getting help...
I don't want to be mean, quite the opposite: I just want to explain why you probably won't receive any help in the current form. This is not special to the Haskell community, the situation would be very much the same if you posted an equivalent problem of similar size to the Racket/Python/... community. I'm quite sure that most maintainer would be happy to have a look e.g. at a program consisting of a dozen lines without external dependencies.

Am Fr., 22. Feb. 2019 um 11:39 Uhr schrieb Damien Mattei < damien.mattei@gmail.com>:
[...] but i think it's the 8.2 compiler that cause the bug...
After a quick look at your code, I very much doubt that. You use the mysql-simple package, which in turn uses the mysql package, which in turn uses the native mysqlclient library. My (and probably most people's) reaction here is: It is much, much more probable that either a) you use the package/library incorrectly or b) the package/library has a bug than that you have discovered a compiler bug for otherwise farily trivial code. Your best bet is to either rip out the mysql dependencies and still reproduce the bug or issue a bug report at e.g. https://github.com/paul-rouse/mysql-simple/issues. Note that I'm not saying that GHC is bug-free, it is just a question where people will probably like to spend their time on. Given the fact that there are tons of buggy packages/libraries with questionable quality out there, it is basically *your* onus to show that your problem is GHC's fault. Just my 2c...

it's not me that say first ghc can have bug. There is a misunderstanding, i
first thought that if there was a problem it was not the core ghc
interpreter/compiler (note that i never try to compile with ghc, possible
the behavior is different in interpreter than in compile mode) but i had a
lot of doubt about the stability of the mysql* packages.
BUT i just made more test with the same mysql* package (version is the
latest,just installed with cabal) on another system this time 32bits:
[mattei@asteroide ~]$ uname -a
Linux asteroide 3.10.0-862.3.3.el7.x86_64 #1 SMP Fri Jun 15 04:15:27 UTC
2018 x86_64 x86_64 x86_64 GNU/Linux
[mattei@asteroide ~]$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[mattei@asteroide ~]$ ghci
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
ghci version 8.4.3
and the program works fine, this does not means that the ghci v8.2 have
bugs nor the mysql* packages , just means that there is some
incompatibilies between ghc 8.2 and the latest versions of mysql* packages
(mysql-simple-0.4.5)
i think there is something that can be enhanced in the cabal or the package
installion script of mysql* packages to detect those incompatibilities but
i do not know how, perheaps if with cabal and ghc 8.2 i had installed an
earlier verison of mysql* it could have worked without problem.
Damien
On Fri, Feb 22, 2019 at 12:35 PM Sven Panne
Am Fr., 22. Feb. 2019 um 11:39 Uhr schrieb Damien Mattei < damien.mattei@gmail.com>:
[...] but i think it's the 8.2 compiler that cause the bug...
After a quick look at your code, I very much doubt that. You use the mysql-simple package, which in turn uses the mysql package, which in turn uses the native mysqlclient library. My (and probably most people's) reaction here is: It is much, much more probable that either
a) you use the package/library incorrectly
or
b) the package/library has a bug
than that you have discovered a compiler bug for otherwise farily trivial code. Your best bet is to either rip out the mysql dependencies and still reproduce the bug or issue a bug report at e.g. https://github.com/paul-rouse/mysql-simple/issues.
Note that I'm not saying that GHC is bug-free, it is just a question where people will probably like to spend their time on. Given the fact that there are tons of buggy packages/libraries with questionable quality out there, it is basically *your* onus to show that your problem is GHC's fault.
Just my 2c...

Well, it's kind of difficult to tell if it's a compiler bug without at least trying different GHC versions. As it stands I don't think there's enough information to diagnose the problem. Perhaps provide something reproducible that we could build on our machines? Cheers, Vanessa McHale On 2/21/19 9:13 AM, Damien Mattei wrote:
my code is structured like this , in summary:
-- this function will return th N°BD from Sidonie for a given name -- note: names have been standardized between Sidonie and WDS getAlphaDelta :: Connection -> String -> IO (Double,Double) getAlphaDelta conn name = do let qry_head_AlphaDelta_AngularDistance = "select alpha,delta from AngularDistance where Nom = ?" :: Query (alpha_delta_rows :: [(Double,Double)]) <- query conn qry_head_AlphaDelta_AngularDistance (Only (name::String)) -- putStrLn $ show alpha_delta_rows return (head alpha_delta_rows)
main =
do conn <- connect defaultConnectInfo { connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie" }
-- check getAlphaDelta works: let name3 = "A 7" putStrLn $ show name3 ad3 <- getAlphaDelta conn name3 putStr "ad3 =" putStrLn $ show ad3
this works i got result such as: "A 7" ad3 =(11297.0,-619.0)
if i move the 5 lines of code at the end of file it segfault
between the begin and end i have some DB connection and queriung , filtering, mapping...
any idea?
should i really upgrade the version of GHCI?
Damien
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

should i really upgrade the version of GHCI?
I don't follow. Do you get a segfault when interpreting your code in ghci, or when compiling your program to a binary with ghc? And on what platform? If you get a segfault, it is often worth running your program under gdb, and check in the crash backtrace whether it crashed from Haskell code or a C foreign function call. Niklas

On 21/02/2019 6:48 PM, Niklas Hambüchen wrote:
Do you get a segfault when interpreting your code in ghci, or when compiling your program to a binary with ghc?
Ah, I see now that there was another email thread where you said it was in ghci, but you didn't to that one in your email so I missed it. I guess my recommendations stands: Try attach to your ghci with gdb and check whether you get a C location for your crash.
participants (5)
-
Artem Pelenitsyn
-
Damien Mattei
-
Niklas Hambüchen
-
Sven Panne
-
Vanessa McHale