#2502: segfault with GHC.Handle.fdToHandle'
---------------------+------------------------------------------------------
 Reporter:  EricKow  |          Owner:             
     Type:  bug      |         Status:  new        
 Priority:  normal   |      Milestone:  6.10 branch
Component:  None     |        Version:  6.8.3      
 Severity:  normal   |     Resolution:             
 Keywords:           |     Difficulty:  Unknown    
 Testcase:           |   Architecture:  x86        
       Os:  FreeBSD  |  
---------------------+------------------------------------------------------
Comment (by thorkilnaur):

 With
 {{{
 $ uname -a
 FreeBSD tn12.thorkilnaur.dk 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12
 10:40:27 UTC 2007
 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/GENERIC  i386
 $ ghc --version
 The Glorious Glasgow Haskell Compilation System, version 6.10.1
 $
 }}}
 I can do
 {{{
 $ cat t1.hs
 import GHC.Handle ( fdToHandle' )
 import IO ( IOMode(..) )

 main = fdToHandle' 1 Nothing False "stdout" WriteMode True
 $ ghc -fforce-recomp --make t1.hs -threaded
 [1 of 1] Compiling Main             ( t1.hs, t1.o )
 Linking t1 ...
 $ ./t1
 $ ghc -fforce-recomp --make t1.hs -threaded -optl-pthread
 [1 of 1] Compiling Main             ( t1.hs, t1.o )
 Linking t1 ...
 $ ./t1
 Segmentation fault: 11 (core dumped)
 $
 }}}
 Studying the {{{gcc}}} and {{{ld}}} command lines produced by {{{ghc}}}
 using {{{-v}}}, I find that {{{-optl-pthread}}} (as one would expect) adds
 {{{-pthread}}} to the {{{gcc}}} command for performing the link. This, in
 turn, causes {{{-lpthread}}} to be added to the {{{ld}}} command. Now, the
 {{{ld}}} command already has {{{-lthr}}} which prompted a search which
 uncovered
 
http://planet.gentoo.org/developers/lavajoe/2007/09/17/spinning_my_tires_in_bug_mud.
 According to Joe Peterson in this reference, libthr is the newer FreeBSD
 threading library, replacing the older libpthread. And, again according to
 the quoted reference, at least in older FreeBSDs (like the 6.2 I am using
 here), mixing the two could lead to segmentation faults, in spite of
 libpthread being "mapped to libthr by libmap.conf".

 Summing all this up, I would say that this is a FreeBSD problem, not a GHC
 problem. And, of course, the work-around is not to use the {{{-optl-
 pthread}}} flag, which doesn't appear to be necessary in any case. So I
 suggest that we close this ticket.

 Best regards
 Thorkil

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2502#comment:6>
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

Reply via email to