#5423: Registers above R8 corrupt when called through prim import
---------------------------------+------------------------------------------
    Reporter:  pumpkin           |       Owner:              
        Type:  bug               |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:  7.2.1             |    Keywords:              
    Testcase:                    |   Blockedby:              
          Os:  Unknown/Multiple  |    Blocking:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 I write a cmm function:
 {{{
 primbug
 {
   foreign "C" printf("%d %d %d %d %d %d %d %d %d\n", R1, R2, R3, R4, R5,
 R6, R7, R8, R9);
   RET_N(R9);
 }
 }}}

 and a binding to it in Haskell:
 {{{
 foreign import prim "primbug" primbug :: Int# -> Int# -> Int# -> Int#
                                       -> Int# -> Int# -> Int# -> Int#
                                       -> Int#
                                       -> Int#

 -- This should resemble id
 bug :: Int -> Int
 bug (I# i) = I# (primbug 0# 111# 222# 333# 444# 555# 666# 777# i)

 main = print (bug 888)
 }}}

 and the program outputs:

 {{{
 0 111 222 333 444 555 666 777 0
 0
 }}}

 The contents of R9 have been lost somehow! The result of this corruption
 isn't always 0, if that helps track it down: in my more complicated use
 case, I'm getting smallish numbers (two hex digits) instead of a
 legitimate pointer.

 I'm attaching a small cabal package to help reproduce it, because it's a
 pain to build.

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