Ticket #5423 (closed bug: fixed)
Registers above R8 corrupt when called through prim import
| Reported by: | pumpkin | Owned by: | igloo |
|---|---|---|---|
| Priority: | high | Milestone: | 7.4.1 |
| Component: | Compiler | Version: | 7.2.1 |
| Keywords: | Cc: | ekmett@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

