Closed Bug 339782 Opened 18 years ago Closed 17 years ago

[ARM] XPTC_InvokeByIndex crashes when cross-compiled under GCC 3.4.x with EABI (CodeSourcery)

Categories

(Core :: XPCOM, defect)

Other
Linux
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: gdx, Assigned: blassey)

Details

Attachments

(1 file, 3 obsolete files)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.7
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.7

I crosscompiled Firefox 1.5.0.1 under http://scratchbox.org/ using CodeSourcery toolchain with EABI support (ARM) and I have problem to run even ./TestXPTCInvoke

$ ./TestXPTCInvoke
calling direct:
        1 + 1 = 2
        1L + 1L = 2
        2 * 2 = 4
        2L * 2L = 4
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
        1 + 2 = 3.000000f
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55.000000
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55.000000f
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 +1 15 + 16 + 17 + 18 + 19 + 20 = 210.000000f
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
        1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 = 66.000000
        moo cow = milk
calling via invoke:
        1 + 1 = 2
        1L + 1L = 0
Segmentation fault (core dumped)



Reproducible: Always
erm, complete steps (including full urls, not generic "http://vendor/" ones) to get codesourcery toolchain would be nice (telling me specific steps for downloading and using scratchbox to configure it are fine, i'd even settle for debian or similar package steps). ignoring that, please build w/ --enable-debugger-info-modules (--enable-debug would be better) --disable-strip, and get a stack trace from gdb (see the unix debugging faq <http://www.mozilla.org/unix/debugging-faq.html>).

that said, i'm using gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2). according to gcc it's compiled with --target=arm-none-linux-gnueabi, and i don't have problems with mozilla-trunk.

unfortunately my scratchbox is busy in the x86 configuration atm, so i can't coax it into giving me TestXPTCInvoke.
(In reply to comment #1)
> erm, complete steps (including full urls, not generic "http://vendor/" ones) to
> get codesourcery toolchain would be nice (telling me specific steps for
> downloading and using scratchbox to configure it are fine, i'd even settle for

I'm using toolchain from http://scratchbox.org/download/files/sbox-releases/stable/tarball/scratchbox-toolchain-arm-gcc3.44csn-glibc2.3-1.0.3-i386.tar.gz

> debian or similar package steps). ignoring that, please build w/
> --enable-debugger-info-modules (--enable-debug would be better)
> --disable-strip, and get a stack trace from gdb (see the unix debugging faq
> <http://www.mozilla.org/unix/debugging-faq.html>).

(...)
Reading symbols from /lib/ld-linux.so.3...done.
Loaded symbols for /lib/ld-linux.so.3
#0  0x400dc498 in XPTC_InvokeByIndex (that=0x16560, methodIndex=0,
    paramCount=16, params=0xbe9f3ac0) at xptcinvoke_arm.cpp:217
217         );
(gdb) bt
#0  0x400dc498 in XPTC_InvokeByIndex (that=0x16560, methodIndex=0,
    paramCount=16, params=0xbe9f3ac0) at xptcinvoke_arm.cpp:217
Cannot access memory at address 0x0
(gdb)

 
> that said, i'm using gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2).
> according to gcc it's compiled with --target=arm-none-linux-gnueabi, and i
> don't have problems with mozilla-trunk.

This is very strange because is exactly the same toolchain.


sh-2.05b$ export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH
sh-2.05b$ ./TestXPTCInvoke
sh-2.05b$ ./TestXPTCInvoke --help
sh-2.05b$ uname -a
Linux swift 2.6.16-1-686-smp #2 SMP Tue Apr 25 20:45:37 UTC 2006 arm GNU/Linux
sh-2.05b$ gcc -v
Reading specs from /scratchbox/compilers/cs2005q3.2-glibc-arm/lib/gcc/arm-none-linux-gnueabi/3.4.4/specs
Reading specs from /scratchbox/compilers/cs2005q3.2-glibc-arm/gcc.specs
rename spec cpp to old_cpp
Configured with: /home/kl/cs2005q3-2_toolchain/gcc/glibc/work/gcc-2005q3-2/configure --target=arm-none-linux-gnueabi --host=i386-linux --build=i386-linux --prefix=/scratchbox/compilers/cs2005q3.2-glibc-arm --with-headers=/scratchbox/compilers/cs2005q3.2-glibc-arm/usr/include --enable-languages=c,c++ --enable-shared --enable-threads --disable-libssp --disable-libstdcxx-pch --disable-checking --enable-__cxa_atexit --program-transform-name=s/^-/arm-linux-/ --program-prefix=arm-linux- --with-cpu= --enable-interwork
Thread model: posix
gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2)

no crash. quite happy. i can check to see if we have any evil patches floating around. if we do, this bug is a duplicate.

ok, we have two patches of interest
one to xpcom/reflect/xptcall/src/md/unix/xptcinvoke_arm.cpp and one to xpcom/reflect/xptcall/src/md/unix/Makefile.in

now i just need to figure out which bug covers them.
Whiteboard: DUPEME
in the future, please search before filing bugs. that bug is in the same component as this one and has enough of the same keywords in the summary that it should have been found.

*** This bug has been marked as a duplicate of 322806 ***
Status: UNCONFIRMED → RESOLVED
Closed: 18 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
(In reply to comment #4)
> in the future, please search before filing bugs. that bug is in the same
> component as this one and has enough of the same keywords in the summary that
> it should have been found.

Of course I tried patch from bug 322806 but it did't help.

I think that PRUint64 and double has bad alignment on the stack. During compile I have warnings:

xptcinvoke_arm.cpp: In function `void invoke_copy_to_stack(PRUint32*, PRUint32, nsXPTCVariant*)':
xptcinvoke_arm.cpp:112: warning: cast from `PRUint32*' to `PRInt64*' increases required alignment of target type
xptcinvoke_arm.cpp:116: warning: cast from `PRUint32*' to `PRUint64*' increases required alignment of target type
xptcinvoke_arm.cpp:118: warning: cast from `PRUint32*' to `double*' increases required alignment of target type
I forgot add that my toolchain is a little diffrent:

$ gcc -v
Reading specs from /scratchbox/compilers/arm-linux-cs344-2.3/bin/../lib/gcc/arm-none-linux-gnueabi/3.4.4/specs
Reading specs from /scratchbox/compilers/arm-linux-cs344-2.3/gcc.specs
rename spec cpp to old_cpp
Configured with: /scratch/paul/2005q3-2/src/gcc-2005q3/configure --disable-nls --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-languages=c,c++ --enable-shared --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --disable-checking --prefix=/opt/codesourcery --enable-symvers=gnu --enable-__cxa_atexit --enable-threads --enable-shared --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/paul/2005q3-2/install/linux-gnueabi/arm-none-linux-gnueabi/libc
Thread model: posix
gcc version 3.4.4 (release) (CodeSourcery ARM 2005q3-2)
i'll look at this again tomorrow. also, if you're trying patches, it'd definitely help if you indicate things you try and whether they help/hurt/do nothing when you file the bug. (unfortunately i have ~100 patches in my tree and i'm very new to it, since someone else collected them for me.)
Timeless could you show me yours options to mozilla and patches which you applies please?
sorry, i really am working on getting to this. but i have quite a number of things i need to do and this is among them.
i'm going to reopen this since the reporter disagrees. i'll try to find someone who can track this down.
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
I am using Codesourcery ARM tolchain and,
I have no such problems with current trunk + patch from bug 
https://bugzilla.mozilla.org/show_bug.cgi?id=349002

https://bugzilla.mozilla.org/attachment.cgi?id=247274

Grzegorz you try trunk + this patch?

timeless could you apply this patch?
Seeing the same TestXPTCInvoke crash as the original reporter, additionally firefox crashes on startup. Attached patch fixes both. 

The crashes are due to xptcall creating bad call stack in some conditions due to new alignment requirements in EABI.
Attachment #284299 - Attachment description: Fixes EABI alignment issues in xptcall → Patch to fix EABI related alignment issues in xptcall
Attachment #284299 - Flags: review?(timeless)
+#define DOUBLEWORD_ALIGN(p) ((PRUint32 *)((((PRUint32)(p)) + 7) & 0xfffffff8))
...

Maybe it possible to move this macro somewhere in xptcall.h, near nsXPTCMiniVariant ....?
Possible, yes, but is it really a good idea to put a very machine specific piece of code into a public header?
Attachment #284299 - Flags: review?(timeless) → review+
being cautious until we know this doesn't break other stuff
Attachment #284299 - Attachment is obsolete: true
Assignee: nobody → dougt
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 287567 [details] [diff] [review]
Updated patch to be specific to EABI

can you move this comment up to where we define VAR_STACK_SIZE_64:

+
+    /* Note that we give a "worst case" estimate of how much stack _might_ be
+     * needed (for __ARM_EABI__), rather than the real count - this should be safe */
+


w/ that change r=
Attachment #287567 - Flags: review+
Attachment #287567 - Flags: superreview?(benjamin)
Attached patch Same as above, but comment moved (obsolete) — Splinter Review
comment moved per dougT's request
Attachment #287745 - Flags: superreview?(benjamin)
Attachment #287745 - Flags: review-
Attachment #287567 - Attachment is obsolete: true
Attachment #287567 - Flags: superreview?(benjamin)
Comment on attachment 287745 [details] [diff] [review]
Same as above, but comment moved

dougt, did you mean to r- here?
Comment on attachment 287745 [details] [diff] [review]
Same as above, but comment moved

this is working for me. lets get a quick SR on this so that we can get this landed.
Attachment #287745 - Flags: superreview?(benjamin)
Attachment #287745 - Flags: superreview?
Attachment #287745 - Flags: review-
Attachment #287745 - Flags: review+
Comment on attachment 287745 [details] [diff] [review]
Same as above, but comment moved

requesting SR from the wind isn't very quick at all. :(
Attachment #287745 - Flags: superreview? → superreview?(benjamin)
Comment on attachment 287745 [details] [diff] [review]
Same as above, but comment moved

>diff --git a/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp b/xpcom/reflect/xptcall/src/md/unix/xptcstubs_arm.cpp

> #include "xptcprivate.h"
> #include "xptiprivate.h"
>+//#include <stdio.h>

Since this is debugging-only I'd wager, please remove it completely.

> static nsresult
> PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, PRUint32* args)
> {
>+
>+    /*
>+#ifdef __ARM_EABI__
>+    printf("__ARM_EABI__\n");
>+#else
>+    printf("not __ARM_EABI__\n");
>+#endif
>+    */

This was for debugging, right? remove it or explain what it's for ;-)
Attachment #287745 - Flags: superreview?(benjamin) → superreview+
Attachment #292771 - Flags: superreview? → superreview?(benjamin)
Attachment #292771 - Flags: superreview?(benjamin) → superreview+
Flags: blocking1.9?
Attachment #292771 - Flags: approval1.9?
this is ARM specific.
Assignee: dougt → blassey
Comment on attachment 292771 [details] [diff] [review]
removed commented out garbage that bsmedberg pointed out

a=beltzner for 1.9
Attachment #292771 - Flags: approval1.9? → approval1.9+
Keywords: checkin-needed
thanks!
Status: NEW → RESOLVED
Closed: 18 years ago17 years ago
Resolution: --- → FIXED
fixed.
Keywords: checkin-needed
Flags: blocking1.9?
Comment on attachment 292771 [details] [diff] [review]
removed commented out garbage that bsmedberg pointed out

We need this to get a working tbird 2 on arm in ubuntu.

I think it should be save enough to approve to 1.8.1 branch especially given that ffox is eol already.
Attachment #292771 - Flags: approval1.8.1.next?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: