runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[ARM/Linux] dumpil fails with floats

Open kvochko opened this issue 10 years ago • 8 comments

When dumping IL assembly for a simple function that contains a float, SOS fails with SIGBUS: illegal alignment. The function I am trying to show IL for is this:

  public static void Main(string[] args)
  {
    float f = 0.5f;
    Console.WriteLine("f = " + f);
  }

The error I am getting is as follows.

(lldb) dumpil b5a9d2a8
Process 26947 stopped
* thread dotnet/coreclr#1: tid = 26947, 0xabc787f8 libsos.so`float readData<float>() + 20 at sildasm.cpp:73, name = 'lldb', stop reason = signal SIGBUS: illegal alignment
    frame #0: 0xabc787f8 libsos.so`float readData<float>() + 20 at sildasm.cpp:73

I suspect this is because ARM requires the stack to be 8-byte aligned, but disassembly for readData shows that 4 bytes are subtracted from the sp register at the start of the function:

(lldb) dis    
libsos.so`readData<float>:
    0xabc787e4 <+0>:  sub    sp, #0x4
...
->  0xabc787f8 <+20>: vstr   s0, [sp]
...

CC @mikem8361 @janvorli @Dmitri-Botcharnikov @lucenticus @papaslavik

kvochko avatar Jul 21 '16 16:07 kvochko

@kvochko @chunseoklee Is there any update for this ?

hqueue avatar Mar 06 '17 05:03 hqueue

@hqueue yes, the problem is most likely in the way readData function is implemented:

// The UNALIGNED is because on IA64 alignment rules would prevent
// us from reading a pointer from an unaligned source.
template <typename T>
T readData ( ) {
    T val = *((T UNALIGNED*)(pBuffer+position));
    position += sizeof(T);
    return val;
}

ARM doesn't seem to support this kind of unaligned access, so using memcpy instead of assignment should solve the problem

kvochko avatar Mar 07 '17 08:03 kvochko

@kvochko I see. Then do you have plan to fix this soon ?

hqueue avatar Mar 08 '17 12:03 hqueue

@chunseoklee Can you take a look at this ?

hqueue avatar Jul 10 '17 05:07 hqueue

@hqueue Is this still a bug?

BruceForstall avatar Apr 25 '18 00:04 BruceForstall

@BruceForstall Let me check but I also have to ask @chunseoklee and @kvocho again.

hqueue avatar Apr 25 '18 12:04 hqueue

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.

ghost avatar Oct 27 '22 06:10 ghost

This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

ghost avatar Nov 10 '22 12:11 ghost