[GHC] #7411: Exceptions are optimized away in certain situations

GHC ghc-devs at haskell.org
Mon Jun 4 07:12:27 UTC 2018


#7411: Exceptions are optimized away in certain situations
-------------------------------------+-------------------------------------
        Reporter:  SimonHengel       |                Owner:  tdammers
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:  seq, deepseq,
                                     |  evaluate, exceptions
Operating System:  Linux             |         Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  Incorrect result  |            Test Case:
  at runtime                         |  simplCore/should_fail/T7411
      Blocked By:                    |             Blocking:
 Related Tickets:  #5129             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by tdammers):

 Ran a few test, and I'm getting perplexing results.

 First of all, a full GHC build from scratch, with `-fno-state-hack`
 everywhere, gives mixed results:

 Regular profiling build:
 {{{
 real    66m1.181s
 user    118m55.812s
 sys     6m9.724s
 }}}

 Profiling build with `-fno-state-hack` enabled:
 {{{
 real    66m25.030s
 user    119m48.580s
 sys     6m7.568s
 }}}

 So the difference is small, `real` and `sys` (which, I believe, is what
 counts) slightly in favor of removing the state hack, `user` in favor of
 keeping it.

 I've also done `nofib` runs with both compilers, also enabling / disabling
 the state hack accordingly; however it turns out that disabling the state
 hack causes `nofib` to fail:

 {{{
 ------------------------------------------------------------------------
 == make all --no-print-directory;
  in /home/tobias/well-typed/devel/ghc/HEAD/nofib/shootout/fasta
 ------------------------------------------------------------------------
 HC = /home/tobias/well-typed/devel/ghc/HEAD/inplace/bin/ghc-stage2
 HC_OPTS = -O2 -Rghc-timing -H32m -hisuf hi -fno-state-hack -O2 -rtsopts
 -O2 -XBangPatterns -XOverloadedStrings -package bytestring
 RUNTEST_OPTS = -ghc-timing
 ==nofib== fasta: time to compile Main follows...
 /home/tobias/well-typed/devel/ghc/HEAD/inplace/bin/ghc-stage2 -O2 -Rghc-
 timing -H32m -hisuf hi -fno-state-hack -O2 -rtsopts -O2 -XBangPatterns
 -XOverloadedStrings -package bytestring -c Main.hs -o Main.o

 Main.hs:30:1: warning: [-Wtabs]
     Tab character found here, and in 13 further locations.
     Please use spaces instead.
    |
 30 |         let !k = min modulus (floor (fromIntegral modulus *
 (p::Float) + 1))
    | ^^^^^^^^
 <<ghc: 401958512 bytes, 72 GCs, 10720054/28796976 avg/max bytes residency
 (6 samples), 61M in use, 0.001 INIT (0.001 elapsed), 0.342 MUT (0.420
 elapsed), 0.240 GC (0.238 elapsed) :ghc>>
 ==nofib== fasta: size of Main.o follows...
    text    data     bss     dec     hex filename
    7245    2624       0    9869    268d Main.o
 ==nofib== fasta: time to link fasta follows...
 <<ghc: 49626024 bytes, 45 GCs, 1356153/2672728 avg/max bytes residency (5
 samples), 8M in use, 0.001 INIT (0.001 elapsed), 0.025 MUT (0.468
 elapsed), 0.060 GC (0.060 elapsed) :ghc>>
 ==nofib== fasta: size of fasta follows...
    text    data     bss     dec     hex filename
  708996  127712   16232  852940   d03cc fasta
 ==nofib== fasta: time to run fasta follows...
 ../../runstdtest/runstdtest ./fasta  -o1 fasta.stdout -o1 fasta.stdout
 -ghc-timing     2500000;   ../../runstdtest/runstdtest ./fasta  -o1
 fasta.stdout -o1 fasta.stdout  -ghc-timing     2500000;
 ../../runstdtest/runstdtest ./fasta  -o1 fasta.stdout -o1 fasta.stdout
 -ghc-timing     2500000;   ../../runstdtest/runstdtest ./fasta  -o1
 fasta.stdout -o1 fasta.stdout  -ghc-timing     2500000;
 ../../runstdtest/runstdtest ./fasta  -o1 fasta.stdout -o1 fasta.stdout
 -ghc-timing     2500000;
 0.43user 0.02system 0:00.45elapsed 99%CPU (0avgtext+0avgdata
 4824maxresident)k
 0inputs+49656outputs (0major+608minor)pagefaults 0swaps
 ././fasta 2500000 < /dev/null
 expected stdout not matched by reality
 --- fasta.stdout        2018-06-02 03:00:43.887025433 +0200
 +++ /tmp/runtest4673.1  2018-06-02 03:09:19.651755697 +0200
 @@ -83337,333335 +83337,333335 @@
  cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg
 -tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa
 -NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt
 -cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga
 -gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa
 -HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca
 #### ~3.1 million similar lines follow ####
 -taatataagctgcgccaggggatttttccagatcatctggcctgtgtatatgttcaaatc
 +gacgaatatattagttatagtttactatccaaataaattaagcgaatcgaaataaactgt
 +gacgaatatattagttatagtttactatccaaataaattaagcgaatcgaaataaactgt
 +gacgaatatattagttatagtttactatccaaataaattaagcgaatcgaaataaactgt
 #### ~208k identical lines follow
 +gacgaatatattagttatagtttactatccaaataaattaagcgaatcgaaataaactgt
  taatagccgagagaaattac
 ../../mk/target.mk:101: recipe for target 'runtests' failed
 make[2]: *** [runtests] Error 1
 Failed making all in fasta: 1
 ../mk/ghc-recurse.mk:65: recipe for target 'all' failed
 make[1]: *** [all] Error 1
 Failed making all in shootout: 1
 mk/ghc-recurse.mk:65: recipe for target 'all' failed
 make: *** [all] Error 1
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7411#comment:35>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list