[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Another bug in ARAnyM?

On Sat, Dec 22, 2007 at 11:34:08AM +0300, Sergei Golovan wrote:
> Hi!
> While playing with Erlang m68k build in ARAnyM and debugging Erlang
> shell crash I've found code similar to the following:
> The code uses implicit conversion from long to a pointer
> (the test is available at http://sgolovan.nes.ru/tmp/test.tar.gz).
> In ARAnym the test gives
> 84
> -1072577264

It does so on actual hardware, too.

> while on all other machines (non-m68k though) it gives
> 84
> 84
> Is this a bug in ARAnyM or it is a difference between m68k and other
> architectures?

This is definately not a bug in ARAnyM.

On m68k, there are three sets of registers: the address registers (A0
through A7), the data registers (D0 through D7), and the floating
point registers (FP0 through FP7). The m68k ABI specifies that floating
point return values should be stored in FP0, that integer return values
should be stored in D0 (or split across D0 and D1 if it's a 64-bit
value), and that pointers should be stored in A0.

Your f() function returns a 32bit integer value, so it stores it in D0.
However, your main() function thinks f() returns a pointer, so will look
for a return value in A0. A0 does not have the value you're looking for,
but something entirely different (it happens to be a constant value,
probably some bits in libc use A0 at some point during its process
initialization bits).

In short, your code is doing stuff it shouldn't be doing.

<Lo-lan-do> Home is where you have to wash the dishes.
  -- #debian-devel, Freenode, 2004-09-22

Reply to: