GHC: Ticket Query
http://ghc.haskell.org/trac/ghc/query?component=libraries%2Fbase&milestone=7.4.1&group=status&order=priority
The Glasgow Haskell Compileren-USGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/query?component=libraries%2Fbase&milestone=7.4.1&group=status&order=priority
Trac 1.0.1
http://ghc.haskell.org/trac/ghc/ticket/3898
http://ghc.haskell.org/trac/ghc/ticket/3898#3898: Many floating point documentation/behaviour mismatches.Thu, 25 Feb 2010 16:07:00 GMTdraconx<p>
I was looking at the haddock documentation for the Prelude to find out what the heck isIEEE did (which didn't actually help: what makes a value an "IEEE floating point number"? I'm guessing it is a constant function which indicates conformance of the _type_ to a particular standard), when I found a number of mismatches between the documentation and the behaviour.
</p>
<ul><li>The documentation for scaleFloat says "multiplies a floating point number by an integer power of the radix". But it doesn't do this:
</li></ul><pre class="wiki">floatRadix (1/0)
--> 2
1/0 * 2^^(-1)
--> Infinity
scaleFloat (-1) (1/0)
--> 8.98846567431158e307
</pre><p>
In this case, I consider the documentation correct and the implementation wrong: scaleFloat should behave similarly to C's scalbln.
</p>
<ul><li>The documentation for exponent says "the second component of decodeFloat".
</li></ul><pre class="wiki">decodeFloat 5
--> (5629499534213120,-50)
exponent 5
--> 3
</pre><p>
In this case, it is probably just the documentation that is wrong.
</p>
<ul><li>The documentation for encodeFloat says "performs the inverse of decodeFloat".
</li></ul><pre class="wiki">id $ 0/0
--> NaN
uncurry encodeFloat . decodeFloat $ 0/0
--> -Infinity
</pre><p>
In this case, I'm not sure which is wrong.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/3898#changelog
http://ghc.haskell.org/trac/ghc/ticket/4400
http://ghc.haskell.org/trac/ghc/ticket/4400#4400: Asynchronous exceptions in runInUnboundThreadThu, 14 Oct 2010 21:45:08 GMTbasvandijk<p>
When you throw an asynchronous exception to a thread which is executing: <tt>runInUnboundThread m</tt>, <tt>m</tt> will keep executing and there's no way to kill it.
</p>
<p>
I propose to catch asynchronous exceptions in <tt>runInUnboundThread</tt> and throw them to the thread which is executing <tt>m</tt>. <tt>m</tt> in turn can decide to catch or ignore them. In case <tt>m</tt> decides to ignore them or to rethrow them, the exception will be rethrown in the current thread:
</p>
<pre class="wiki">runInUnboundThread :: IO a -> IO a
runInUnboundThread action = do
bound <- isCurrentThreadBound
if bound
then do
mv <- newEmptyMVar
mask $ \restore -> do
tid <- forkIO $ Exception.try (restore action) >>= putMVar mv
let wait = takeMVar mv `Exception.catch` \(e :: SomeException) ->
Exception.throwTo tid e >> wait
wait >>= unsafeResult
else action
unsafeResult :: Either SomeException a -> IO a
unsafeResult = either Exception.throwIO return
</pre><p>
The attached patch implements this behaviour.
</p>
<p>
(Note there are two other bug-fix patches in the bundle that this patch depends on which can be independently applied.)
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4400#changelog
http://ghc.haskell.org/trac/ghc/ticket/4526
http://ghc.haskell.org/trac/ghc/ticket/4526#4526: Make Chan an instance of EqThu, 25 Nov 2010 12:46:20 GMTmitar<p>
Chan is not an instance of Eq, but it could be easily, as MVars it uses are.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4526#changelog
http://ghc.haskell.org/trac/ghc/ticket/4537
http://ghc.haskell.org/trac/ghc/ticket/4537#4537: Make SampleVar an instance of TypeableSat, 27 Nov 2010 09:24:18 GMTbasvandijk<p>
Mitar <a class="ext-link" href="http://article.gmane.org/gmane.comp.lang.haskell.libraries/14592"><span class="icon"></span>requested</a> to make <tt>SampleVar</tt> an instance of <tt>Typeable</tt>. This ticket proposes to do that.
</p>
<p>
Deadline: 2 December.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4537#changelog
http://ghc.haskell.org/trac/ghc/ticket/4994
http://ghc.haskell.org/trac/ghc/ticket/4994#4994: Deprecate Control.Exception.blocked in favour of getMaskingStateThu, 03 Mar 2011 00:43:59 GMTbasvandijk<p>
I <a class="ext-link" href="http://www.haskell.org/pipermail/libraries/2011-February/015859.html"><span class="icon"></span>proposed</a> deprecating <tt>Control.Exception.blocked</tt> in
favour of <tt>getMaskingState</tt>.
</p>
<p>
The term "blocked" refers to the old way of dealing with asynchronous
exceptions (<tt>block</tt>/<tt>unblock</tt>). It can also be a bit confusing to which
"blocked" property it refers: blocked asynchronous exceptions, or a
blocked thread.
</p>
<p>
Note that <tt>blocked</tt> is already listed in the section <a class="ext-link" href="http://hackage.haskell.org/packages/archive/base/4.3.0.0/doc/html/Control-Exception.html#12"><span class="icon"></span>(deprecated) Asynchronous exception control</a>
</p>
<p>
There were no objections and one +1 from Simon Marlow.
</p>
<p>
The patch is attached.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4994#changelog
http://ghc.haskell.org/trac/ghc/ticket/5396
http://ghc.haskell.org/trac/ghc/ticket/5396#5396: rare segfault in a terminal gameTue, 09 Aug 2011 07:07:48 GMTMikolajKonarski<p>
The segfault happens with this package: <a class="ext-link" href="http://hackage.haskell.org/package/Allure"><span class="icon"></span>http://hackage.haskell.org/package/Allure</a>, when compiled with flag -fvty. It looks indeterministic, Happened with and without compiling with --ghc-options="-dcore-lint -debug", with and without running under gdb (shows a backtracs of length 3 each time). Happened in a few different versions of the application, with changed code. Quick keystrokes seem to help reproducing it, and/or autorepeat of keys. No luck with finding a reliable way to reproduce. Tested only on one machine; triggered over 10 times for around 5 hours of play total. I'm no longer sure it never happens with other ghc versions (and other frontends), because of how irregular it's appearance is.
</p>
<p>
This version of the application:
</p>
<p>
<a class="ext-link" href="https://github.com/Mikolaj/Allure/commit/a769ee7f30a38574f6402fe677f537077e0b7d69"><span class="icon"></span>https://github.com/Mikolaj/Allure/commit/a769ee7f30a38574f6402fe677f537077e0b7d69</a>
</p>
<p>
has deterministic pseudo-random numbers generation and I managed to trigger the bug twice on a map with manually set random seed 6 (in te config file). Once it happened after a few seconds of play, once after a few minutes, but still on level 1. No luck in many other attempts.
</p>
<p>
The version also has a stdin/stdout frontend and a deterministic bot. By default, the bot is run on the map generated with random seed 6, but it didn't manage to reproduce the bug so far, with many bot seeds. Details of using the bot in the commit log.
</p>
<p>
I will try to diagnose further, but probably not until the last week of August.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5396#changelog
http://ghc.haskell.org/trac/ghc/ticket/5421
http://ghc.haskell.org/trac/ghc/ticket/5421#5421: <<loop>> in withMVar (reproducible, but with large test case)Thu, 18 Aug 2011 04:51:39 GMTJohnMillikin<p>
A user of one of my libraries is reporting that it fails with the message <tt><<loop>></tt> when compiled in GHC 7.2.1. The error is coming from <tt>withMVar</tt>, and is reproducible.
</p>
<p>
Unfortunately, the problem is *very* tricky to reproduce. Attempting to debug it (such as adding print statements, re-ordering operations, or removing unrelated code) will cause it to vanish. Therefore, the test case I have attached is a full Cabal project with build instructions. Nearly every line of code is required, and changing or removing them hides the error again.
</p>
<p>
Changes which can hide the problem:
</p>
<ul><li>Altering or removing the startup messages (even the version number).
</li><li>Removing unused attributes from types.
</li><li>Removing unused error checking.
</li><li>Using <tt>_ <- char 'a'</tt> instead of <tt>void (char 'a')</tt>.
</li><li>Moving a function from one module to another.
</li><li>Simplifying loops which only run over one element.
</li><li>Building it all at once with <tt>--make</tt>, and not a separate <tt>cabal-dev install</tt> step.
</li><li>Building 'Main' with <tt>-O2</tt>.
</li></ul>Resultshttp://ghc.haskell.org/trac/ghc/ticket/5421#changelog
http://ghc.haskell.org/trac/ghc/ticket/5431
http://ghc.haskell.org/trac/ghc/ticket/5431#5431: Add popCount to Data.BitsThu, 25 Aug 2011 08:30:35 GMTtibbe<p>
Now when we have a fast <tt>popCnt#</tt> primop it would be nice to expose it to the world through an official API. I propose we add this method to the <tt>Bits</tt> class in <tt>Data.Bits</tt>:
</p>
<pre class="wiki">-- | Return the number of set bits in the argument, know as the
-- population count or the Hamming weight.
popCount :: a -> Int
</pre><p>
The proposal was discussed and agreed upon in this thread: <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lang.haskell.libraries/16073"><span class="icon"></span>http://thread.gmane.org/gmane.comp.lang.haskell.libraries/16073</a>
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5431#changelog
http://ghc.haskell.org/trac/ghc/ticket/5536
http://ghc.haskell.org/trac/ghc/ticket/5536#5536: IO performance regression in 7.2 vs 7.0Fri, 07 Oct 2011 14:11:17 GMTsimonmar<p>
The following program:
</p>
<pre class="wiki">main = interact id
</pre><p>
runs about a third slower in 7.2.1 compared to 7.0.3 (and current 7.3 is about the same as 7.2.1).
</p>
<p>
With 7.2.1:
</p>
<pre class="wiki">$ ls -l stuff
-rw-rw-r-- 1 simonmar GHC 128464904 2011-10-07 14:59 stuff
$ ./cat <stuff >/dev/null +RTS -s
8,357,007,912 bytes allocated in the heap
793,616,736 bytes copied during GC
83,984 bytes maximum residency (1 sample(s))
24,936 bytes maximum slop
1 MB total memory in use (0 MB lost due to fragmentation)
Tot time (elapsed) Avg pause Max pause
Gen 0 15966 colls, 0 par 0.94s 0.94s 0.0001s 0.0001s
Gen 1 1 colls, 0 par 0.00s 0.00s 0.0004s 0.0004s
INIT time 0.00s ( 0.00s elapsed)
MUT time 5.71s ( 5.71s elapsed)
GC time 0.94s ( 0.94s elapsed)
EXIT time 0.00s ( 0.00s elapsed)
Total time 6.65s ( 6.65s elapsed)
</pre><p>
and with 7.0.3:
</p>
<pre class="wiki">$ ./cat <stuff >/dev/null +RTS -s
./cat +RTS -s
5,299,570,680 bytes allocated in the heap
250,350,336 bytes copied during GC
53,232 bytes maximum residency (1 sample(s))
30,776 bytes maximum slop
1 MB total memory in use (0 MB lost due to fragmentation)
Generation 0: 10086 collections, 0 parallel, 0.50s, 0.50s elapsed
Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed
INIT time 0.00s ( 0.00s elapsed)
MUT time 4.38s ( 4.38s elapsed)
GC time 0.50s ( 0.50s elapsed)
EXIT time 0.00s ( 0.00s elapsed)
Total time 4.88s ( 4.88s elapsed)
</pre><p>
I strongly suspect this has to do with the changes to the encoding machinery in 7.2.1.
</p>
<p>
In binary mode, the slowdown is even worse. The program:
</p>
<pre class="wiki">import System.IO
main = do
hSetBinaryMode stdin True
hSetBinaryMode stdout True
getContents >>= putStr
</pre><p>
With 7.0.3 this runs in 3.35s, with 7.2.1 it takes 5.49s, a slowdown of 63%.
</p>
<p>
After fixing this, we need to add a performance regression test.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5536#changelog
http://ghc.haskell.org/trac/ghc/ticket/5546
http://ghc.haskell.org/trac/ghc/ticket/5546#5546: Documentation errors in Control.Exception.BaseMon, 10 Oct 2011 14:58:13 GMTbit<p>
I found the following 2 errors in the documentation of <a class="ext-link" href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception-Base.html"><span class="icon"></span>Control.Exception.Base</a>
</p>
<h2 id="catch">catch</h2>
<p>
From the documentation for the <a class="ext-link" href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception-Base.html#v:catch"><span class="icon"></span>catch</a> function:
</p>
<p>
<em>... see the previous section "Catching all exceptions"</em>
</p>
<p>
There is no such section!
</p>
<h2 id="mask">mask</h2>
<p>
From the documentation for the <a class="ext-link" href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception-Base.html#v:mask"><span class="icon"></span>mask</a> function:
</p>
<p>
<em>... the only way is to create a new thread; see Control.Concurrent.forkIOUnmasked.</em>
</p>
<p>
But <a class="ext-link" href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent.html#v:forkIOUnmasked"><span class="icon"></span>forkIOUnmasked</a> is deprecated!
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5546#changelog
http://ghc.haskell.org/trac/ghc/ticket/3339
http://ghc.haskell.org/trac/ghc/ticket/3339#3339: Data.Monoid: Add (<>) as a synonym for mappendTue, 30 Jun 2009 21:36:04 GMTbos<p>
This proposal was, I think, originally suggested by Jules Bean. The idea is to add two functions to the <tt>Data.Monoid</tt> module, <tt>(+>)</tt> and <tt>(<+)</tt>, corresponding to different uses of <tt>mappend</tt>. These should not be methods of the <tt>Monoid</tt> typeclass, but top-level functions.
</p>
<p>
I hope (but slightly doubt) that the visual nature of the two operators might help to counter the thought that monoids are just for gluing things together.
</p>
<pre class="wiki">(+>) :: (Monoid a) => a -> a -> a
a +> b = a `mappend` b
(<+) :: (Monoid a) => a -> a -> a
a <+ b = b `mappend` a
infixl 4 +>
infixl 4 <+
</pre><p>
Proposed deadline: two weeks.
</p>
<p>
If this looks reasonable, I'll attach darcs patches.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/3339#changelog
http://ghc.haskell.org/trac/ghc/ticket/4335
http://ghc.haskell.org/trac/ghc/ticket/4335#4335: fromRational broken for Ratio aFri, 24 Sep 2010 21:47:41 GMTdaniel.is.fischer<p>
The <tt>Fractional</tt> instance for <tt>Ratio a</tt> in GHC.Real defines
</p>
<pre class="wiki"> fromRational (x:%y) = fromInteger x :% fromInteger y
</pre><p>
For fixed-width Integral types, that produces invalid results:
</p>
<pre class="wiki">Prelude Data.Ratio> fromRational (1 % 2^32) :: Ratio Int
1 % 0
Prelude Data.Ratio> fromRational (3 % (2^32+9)) :: Ratio Int
3 % 9
</pre><p>
Via <tt>toRational</tt>, these can be ported back to <tt>Rational</tt>.
</p>
<p>
<tt>Ratio a</tt> is generally broken for fixed-width types:
</p>
<pre class="wiki">Prelude Data.Ratio> 1 % (minBound :: Int)
(-1) % (-2147483648)
</pre><p>
but the particular brokenness of <tt>fromRational</tt> can be alleviated by reducing:
</p>
<pre class="wiki"> fromRational (x:%y) = fromInteger x % fromInteger y
{-# RULES
"fromRational/id" fromRational = id :: Rational -> Rational
#-}
</pre><p>
I think it's better to throw a divide by zero error than to produce invalid results here.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4335#changelog
http://ghc.haskell.org/trac/ghc/ticket/4810
http://ghc.haskell.org/trac/ghc/ticket/4810#4810: Versions of bracket without masking acquire actionTue, 30 Nov 2010 23:32:48 GMTmitar<p>
With new mask/restore concept it is impossible to unblock exceptions in acquire action which is quite often useful (acquire can be a lengthily action). So it could be a good idea to introduce a variant which has acquire action unmasked.
</p>
<p>
Of course I could write:
</p>
<pre class="wiki">mask $ \restore -> bracket (restore . open) (close) (restore . work)
</pre><p>
but this is just ugly.
</p>
<p>
So I am proposing <tt>bracket'</tt> or <tt>bracketUnmasked</tt> or something.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4810#changelog
http://ghc.haskell.org/trac/ghc/ticket/4855
http://ghc.haskell.org/trac/ghc/ticket/4855#4855: Debug.Trace.trace mangles Unicode stringsTue, 21 Dec 2010 08:01:52 GMTandersk<pre class="wiki">Prelude Debug.Trace> trace "Σὲ γνωρίζω ἀπὸ τὴν κόψη" ()
�r ����w��
()
</pre>Resultshttp://ghc.haskell.org/trac/ghc/ticket/4855#changelog
http://ghc.haskell.org/trac/ghc/ticket/4947
http://ghc.haskell.org/trac/ghc/ticket/4947#4947: Regenerated cbits/WCsubst.c based on Unicode 6.0.0Mon, 07 Feb 2011 19:38:59 GMTbasvandijk<p>
I noticed the generated <tt>cbits/WCsubst.c</tt> was based on Unicode 5.1.0. I regenerated it based on the latest Unicode version:
</p>
<p>
<a class="ext-link" href="http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt"><span class="icon"></span>http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt</a>
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4947#changelog
http://ghc.haskell.org/trac/ghc/ticket/4961
http://ghc.haskell.org/trac/ghc/ticket/4961#4961: Make the Timeout exception a newtype instead of a datatypeTue, 15 Feb 2011 21:29:55 GMTbasvandijk<p>
The attached patch simply replaces the <tt>data</tt> with a <tt>newtype</tt> for the <tt>Timeout</tt> exception in <a class="ext-link" href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/System-Timeout.html"><span class="icon"></span>System.Timeout</a>:
</p>
<pre class="wiki">-data Timeout = Timeout Unique deriving Eq
+newtype Timeout = Timeout Unique deriving Eq
</pre>Resultshttp://ghc.haskell.org/trac/ghc/ticket/4961#changelog
http://ghc.haskell.org/trac/ghc/ticket/5237
http://ghc.haskell.org/trac/ghc/ticket/5237#5237: Inefficient code generated for x^2Thu, 02 Jun 2011 11:47:00 GMTscpmw<p>
Okay, this one is quite surprising to me. Suppose the following trivial Haskell program:
</p>
<pre class="wiki">main = print (2.0 ^ 2)
</pre><p>
This innocent example actually ends up generating multiple pages of Core! To see what's going on we just have to look at a few type signatures:
</p>
<pre class="wiki">$wg1_r11f :: Double# -> Type.Integer -> Double# -> Double#
$wf1 :: Double# -> Type.Integer -> Double#
</pre><p>
The function <tt>$wf1</tt> is what is called to perform the calculation. First thing to note is that it actually compiles <tt>^2</tt> into a <em>loop</em> (that's what <tt>$wg1_r11f</tt> is for). Second, to make matters worse, it ends up using <em>Integer</em> of all things as the index type (defaulting at work, probably).
</p>
<p>
This has obviously drastic performance implications. A more complicated example program actually got about 4 times faster just by replacing all instances of <tt>x^2</tt> with <tt>x*x</tt>.
</p>
<p>
I guess this probably is not easy to fix in the general case (speculative loop unrolling?). But couldn't we have, say, a rule that catches the worst cases?
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5237#changelog
http://ghc.haskell.org/trac/ghc/ticket/5414
http://ghc.haskell.org/trac/ghc/ticket/5414#5414: Add unsafeShift to Data.BitsSun, 14 Aug 2011 10:49:49 GMTtibbe<p>
<tt>shiftL</tt> and <tt>shiftR</tt> introduce an extra branch to check for overflows (i.e. shifts with an amount larger than 32/64). This branch gets removed if the shift amount is statically known, but otherwise leaves a branch in the optimized code, slowing down bit manipulation code.
</p>
<p>
<tt>unsafeShiftL</tt> and <tt>unsafeShiftR</tt> translate directly to the underlying hardware operation (which is undefined for shift amount larger than the architectures word size).
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5414#changelog
http://ghc.haskell.org/trac/ghc/ticket/5512
http://ghc.haskell.org/trac/ghc/ticket/5512#5512: UTF-16//ROUNDTRIP encoding behaves weirdlyTue, 27 Sep 2011 14:14:30 GMTbatterseapower<p>
Try this program:
</p>
<pre class="wiki">module Main where
import System.IO
main = do
roundtrip_enc <- mkTextEncoding "UTF16//ROUNDTRIP"
h <- openFile "out.temp" WriteMode
hSetEncoding h roundtrip_enc
hPutStr h "Hi\xEFE8Hi"
</pre><p>
It fails with:
</p>
<pre class="wiki">hSetEncoding: invalid argument (Invalid argument)
</pre><p>
If you change UTF16 to UTF-16 (so we use the builtin encoding rather than iconv) it works, but the output file only contains the first Hi.
</p>
<p>
I think part of what is going on here is that iconv does not generate EILSEQ for identity transformations such as that between a UTF-16 text file and our UTF-16 CharBuffers. Since we never get that exception, we can't fix up the lone surrogates we use to encode roundtrip characters.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/5512#changelog