Opened 4 years ago

Closed 4 years ago

#4283 closed bug (invalid)

Different behaviour with -O in concurrent program

Reported by: simonpj Owned by: simonmar
Priority: normal Milestone: 7.4.1
Component: Compiler Version: 6.12.3
Keywords: Cc: mmitar@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by simonpj)

Mitar (mmitar@…) reports
I am attaching a program which locks (throws an exception <<loop>>) when compiled like:

ghc --make -threaded -main-is Test.main Test.hs -o test-no-opt -package mtl

and doesn't loop when compiled with

ghc --make -threaded -O2 -main-is Test.main Test.hs -o test-opt -package mtl

This should probably not happen.

I am using 6.12.3 on Linux x86_64.

SimonPJ reproduced this with the HEAD:

simonpj@cam-04-unx:~/tmp$ ./test-opt
42
42
42
42
-- Ctrl-C out
simonpj@cam-04-unx:~/tmp$ ./test-no-opt
42
test-no-opt: <<loop>>
/bin/bash: line 0: echo: write error: Broken pipe
/bin/bash: line 0: echo: write error: Broken pipe
/bin/bash: line 0: echo: write error: Broken pipe
-- Ctrl-C out

It's not 100% clear that it's a bug, but Simon M will look at it.

Attachments (1)

Test.hs (3.3 KB) - added by simonpj 4 years ago.
Test case

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by simonpj

Test case

comment:1 Changed 4 years ago by simonpj

  • Description modified (diff)

comment:2 Changed 4 years ago by mitar

  • Cc mmitar@… added

comment:3 Changed 4 years ago by simonmar

  • Resolution set to invalid
  • Status changed from new to closed

The problem is here:

     let rest' = assert ((fromIntegral $ C.length rest') <= capacity) $ C.pack rest

rest' is _|_, which accounts for the <<loop>>, and the assert is only executed when optimisation is off, which accounts for the different behaviour when compiled with optimisation on.

Note: See TracTickets for help on using tickets.