[Bug c/56473] New: Cross Compile Ubuntu x86_64 to Raspberry Pi Code Seg Faults When Executed
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56473 Bug #: 56473 Summary: Cross Compile Ubuntu x86_64 to Raspberry Pi Code Seg Faults When Executed Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: tomd...@speakeasy.org Created attachment 29548 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29548 Script of the compile/link I compiled and linked on Ubuntu x86_64 for the Raspberry Pi. The compiler/linker completed with no errors. int main() { return 0;} When hello is executed on Raspberry Pi, I got a Segmentation fault. If I compile on Ubuntu with -nostdlib and explicitly list the Raspberry Pi crtxxx.o files and the Raspberry Pi libs, the resultant executable completes without error on Raspberry Pi. I attached a script of the compile actions on Ubuntu. I believe this to be a problem with the crt.o files and the libs distributed with arm-linux-gnueabihf-gcc-4.6 package. The same package on Raspberry Pi works Ok. On Ubuntu > uname -a Linux P9X79 3.2.0-38-generic #60-Ubuntu SMP Wed Feb 13 13:22:43 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux On Raspberry Pi > uname -a Linux raspberrypi 3.2.27+ #250 PREEMPT Thu Oct 18 19:03:02 BST 2012 armv6l GNU/Linux
[Bug target/56473] Cross Compile Ubuntu x86_64 to Raspberry Pi Code Seg Faults When Executed
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56473 --- Comment #3 from Thomas Dean 2013-02-28 00:24:44 UTC --- On Ubuntu, I recompiled with -g On RaspberryPi, I ran gdb on the resulting executable tomdean@raspberrypi:~/p9x79/bug$ gdb hello GNU gdb (GDB) 7.4.1-debian Reading symbols from /home/tomdean/p9x79/bug/hello...done. (gdb) b main Breakpoint 1 at 0x8364: file hello.c, line 3. (gdb) r Starting program: /home/tomdean/p9x79/bug/hello Program received signal SIGSEGV, Segmentation fault. 0x000573a6 in ?? () (gdb) bt #0 0x000573a6 in ?? () #1 0x82ee in _start () I think the ubuntu crtxxx.o files and the unbunt arm-linux-gnueabihf-gcc-4.6 libs were not built correctly. diff says they are not the same as the RaspberryPi files. If I compile on ubuntu and link on RaspberryPi, all is well. If I compile on ubuntu and link, using the crtxxx.o and libs from RaspberryPi, all is well.
[Bug target/56473] Cross Compile Ubuntu x86_64 to Raspberry Pi Code Seg Faults When Executed
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56473 --- Comment #4 from Thomas Dean 2013-02-28 00:38:56 UTC --- Looking again at gdb, _start from ubuntu is not the same as _start on RaspberryPi, although both compiler versions are the same. ### ## build on ubuntu ## gdb on raspi tomdean@raspberrypi:~/p9x79/bug$ gdb hello GNU gdb (GDB) 7.4.1-debian Reading symbols from /home/tomdean/p9x79/bug/hello...done. (gdb) b main Breakpoint 1 at 0x8364: file hello.c, line 3. (gdb) r Starting program: /home/tomdean/p9x79/bug/hello Program received signal SIGSEGV, Segmentation fault. 0x000573a6 in ?? () (gdb) bt #0 0x000573a6 in ?? () #1 0x82ee in _start () (gdb) disassemble/r _start Dump of assembler code for function _start: 0x82e4 <+0>: 4f f0 00 0b mov.w r11, #0 0x82e8 <+4>: 4f f0 00 0e mov.w lr, #0 0x82ec <+8>: 5d f8 04 1b ldr.w r1, [sp], #4 0x82f0 <+12>:6a 46 mov r2, sp 0x82f2 <+14>:4d f8 04 2d str.w r2, [sp, #-4]! 0x82f6 <+18>:4d f8 04 0d str.w r0, [sp, #-4]! 0x82fa <+22>:df f8 14 c0 ldr.w r12, [pc, #20] ; 0x8310 <_start+44> 0x82fe <+26>:4d f8 04 cd str.w r12, [sp, #-4]! 0x8302 <+30>:04 48 ldr r0, [pc, #16] ; (0x8314 <_start+48>) 0x8304 <+32>:04 4b ldr r3, [pc, #16] ; (0x8318 <_start+52>) 0x8306 <+34>:ff f7 da ef blx 0x82bc <__libc_start_main> 0x830a <+38>:ff f7 e6 ef blx 0x82d8 0x830e <+42>:00 00 bd 83 ; instruction: 0x83bd 0x8312 <+46>:00 00 5c 83 cmphi r12, #0 0x8316 <+50>:00 00 79 83 cmnhi r9, #0 0x831a <+54>:00 00 03 4b blmi0xc8322 End of assembler dump. ### ## compile on ubuntu ## link on raspi ## gdb on raspi ubuntu> arm-linux-gnueabihf-gcc-4.6 -g -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -marm hello.c -Wl,-t -c -o hello.o tomdean@raspberrypi:~/p9x79/bug$ arm-linux-gnueabihf-gcc-4.6 -g -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard -marm hello.o -Wl,-t -o ~/work/hello tomdean@raspberrypi:~/p9x79/bug$ gdb ~/work/hello GNU gdb (GDB) 7.4.1-debian Reading symbols from /home/tomdean/work/hello...done. (gdb) b main Breakpoint 1 at 0x8398: file hello.c, line 3. (gdb) r Starting program: /home/tomdean/work/hello Breakpoint 1, main () at hello.c:3 3 return 0; (gdb) disassemble/r _start Dump of assembler code for function _start: 0x82e4 <+0>: 00 b0 a0 e3 mov r11, #0 0x82e8 <+4>: 00 e0 a0 e3 mov lr, #0 0x82ec <+8>: 04 10 9d e4 pop {r1}; (ldr r1, [sp], #4) 0x82f0 <+12>:0d 20 a0 e1 mov r2, sp 0x82f4 <+16>:04 20 2d e5 push{r2}; (str r2, [sp, #-4]!) 0x82f8 <+20>:04 00 2d e5 push{r0}; (str r0, [sp, #-4]!) 0x82fc <+24>:10 c0 9f e5 ldr r12, [pc, #16] ; 0x8314 <_start+48> 0x8300 <+28>:04 c0 2d e5 push{r12} ; (str r12, [sp, #-4]!) 0x8304 <+32>:0c 00 9f e5 ldr r0, [pc, #12] ; 0x8318 <_start+52> 0x8308 <+36>:0c 30 9f e5 ldr r3, [pc, #12] ; 0x831c <_start+56> 0x830c <+40>:eb ff ff eb bl 0x82c0 <__libc_start_main> 0x8310 <+44>:f0 ff ff eb bl 0x82d8 0x8314 <+48>:0c 84 00 00 andeq r8, r0, r12, lsl #8 0x8318 <+52>:90 83 00 00 muleq r0, r0, r3 0x831c <+56>:ac 83 00 00 andeq r8, r0, r12, lsr #7 End of assembler dump.
[Bug libstdc++/43802] New: Tanh Returns Incorrect Value
In c and c++, tanh returns a different incorrect value. test-tanh.c: gcc test-tanh.c -o test-tanh-c-lm test-tanh.cc: g++ test-tanh.cc -o test-tanh-cc ./test-tanh-c 711 libc version 2.10.1 libc release stable arg= 7.11e+02 + 7.11e+02 * i sinh (arg) = inf + inf * i cosh (arg) = inf + inf * i s/c = nan + nan * i (should be 1 + 0 * i) tanh (arg) = 0.00e+00 + 0.00e+00 * i (should be 1 + 0 * i) ./test-tanh-cc 711 libc version 2.10.1 arg (711,711) sinh(arg) (1.64037e+308,2.55507e+308) cosh(arg) (1.64037e+308,2.55507e+308) s/c (1,0) tanh(arg) (1,4.93127e-618) test-tanh.c #include #include #include #define _GNU_SOURCE #include int main (int argc, char **argv) { long double complex arg = 1 + _Complex_I; long double complex s, c, r, t; long mult; if (argc == 2) { mult = atol(argv[1]); } else { mult = 5L; } arg *= mult; s = csinh (arg); c = ccosh (arg); r = s / c; t = ctanh (arg); printf ("libc version %s\n", gnu_get_libc_version ()); printf ("libc release %s\n", gnu_get_libc_release ()); printf ("arg= %e + %e * i\n", creal (arg), cimag (arg)); printf ("sinh (arg) = %e + %e * i\n", creal (s), cimag (s)); printf ("cosh (arg) = %e + %e * i\n", creal (c), cimag (c)); printf("s/c = %e + %e * i (should be 1 + 0 * i)\n", creal (r), cimag (r)); printf ("tanh (arg) = %e + %e * i (should be 1 + 0 * i)\n", creal (t), cimag (t)); return 0; } test-tanh.c #include #include #include #include // atol using namespace std; int main(int argc, char **argv) { long mult; if (argc == 2) { mult = atol(argv[1]); } else { mult = 5L; } complex arg(1,1); arg *= mult; complex s,c,r,t; s=sinh(arg); c=cosh(arg); r=s/c; t=tanh(arg); cout << "libc version " << gnu_get_libc_version() << endl; cout << "arg " << arg << endl; cout << "sinh(arg) " << s << endl; cout << "cosh(arg) " << c << endl; cout << "s/c " << r << endl; cout << "tanh(arg) " << t << endl; return 0; } -- Summary: Tanh Returns Incorrect Value Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tomdean at speakeasy dot org GCC build triplet: Ubuntu 9.10 Distribution GCC host triplet: ubuntu 9.10 GCC target triplet: i686 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43802
[Bug libstdc++/43802] Tanh Returns Incorrect Value
--- Comment #3 from tomdean at speakeasy dot org 2010-04-19 23:33 --- Subject: Re: Tanh Returns Incorrect Value On Mon, 2010-04-19 at 22:56 +, pinskia at gcc dot gnu dot org wrote: > > --- Comment #1 from pinskia at gcc dot gnu dot org 2010-04-19 22:56 > --- > That is because you are using the double version of ctanh rather than the long > double version for the C case. > > Changing the C testcase to use ctanhl and you get the same value for the C/C++ > cases. > > The problem remains. I used a long double to try to demonstrate overflow. Changing all the code to use ctanhl, csinhl, ccoshl, only changed the point at wiich overflow occurs and ctanhl() returns an incorrect value. Note: limit(tanh(n*(1+I)),n=infinity) == 1 Therefore, if the argument to ctanh is not nan or inf, ctanh should return 1 at and above overflow for the type. I only calculated s/c, demonstrating the overflow to another group, octave. Sorry for sending the wrong code, which distracted from the problem. Here is the code I use for the test. As mult increases, you can see the overflow happening. >./test-tanh-c 5678 libc version 2.10.1 libc release stable arg= 5678.00 + 5678.00 * i sinh (arg) = -1.745126e+2465 + -3.818036e+2465 * i cosh (arg) = -1.745126e+2465 + -3.818036e+2465 * i s/c = 1.00 + -0.00 * i tanh (arg) = 1.00 + 0.00 * i >./teat-tanh-c 5679 libc version 2.10.1 libc release stable arg= 5679.00 + 5679.00 * i sinh (arg) = 6.170148e+2465 + -9.599250e+2465 * i cosh (arg) = 6.170148e+2465 + -9.599250e+2465 * i s/c = 1.00 + -0.00 * i tanh (arg) = nan + -0.00 * i < OVERFLOW??? #include #include #include #define _GNU_SOURCE #include int main (int argc, char **argv) { long double complex arg = 1 + _Complex_I; long double complex s, c, r, t; long mult; if (argc == 2) { mult = atol(argv[1]); } else { mult = 5L; } arg *= (long double)mult; s = csinhl (arg); c = ccoshl (arg); r = s / c; t = ctanhl (arg); printf ("libc version %s\n", gnu_get_libc_version ()); printf ("libc release %s\n", gnu_get_libc_release ()); printf ("arg= %Lf + %Lf * i\n", creall (arg), cimagl (arg)); printf ("sinh (arg) = %Le + %Le * i\n", creall (s), cimagl (s)); printf ("cosh (arg) = %Le + %Le * i\n", creall (c), cimagl (c)); printf("s/c = %Lf + %Lf * i\n", creall (r), cimagl (r)); printf ("tanh (arg) = %Lf + %Lf * i\n", creall (t), cimagl (t)); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43802
[Bug libstdc++/43802] Tanh Returns Incorrect Value
--- Comment #5 from tomdean at speakeasy dot org 2010-04-20 01:37 --- Subject: Re: Tanh Returns Incorrect Value On Mon, 2010-04-19 at 23:57 +, pinskia at gcc dot gnu dot org wrote: > > --- Comment #4 from pinskia at gcc dot gnu dot org 2010-04-19 23:57 > --- > And tanhl is a GCC issue how? It is part of glibc and not GCC so please > report > it to them. > Plus it works for me with: > libc version 2.7 > libc release stable > > On Debian 5.0. Sorry, I crossed wires when replying to your previous email. I have two problems, one with libc and the other with libstdc++. and, in gcc-4.4.1/libstdc++-v3/include/std/complex template inline complex<_Tp> __complex_tanh(const complex<_Tp>& __z) { return std::sinh(__z) / std::cosh(__z); } ... template inline complex<_Tp> __complex_sinh(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y)); } ... template inline complex<_Tp> __complex_cosh(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y)); } And, these all seem to resolve to gcc builtin's, like __builtin_coshl(__x);, etc. Is this true? The code below was compiled with: g++ test-tanh.cc -o test-tanh-cc >test-tanh-cc arg (5,5) sinh(arg) (-inf,-inf) cosh(arg) (-inf,-inf) s/c (nan,nan) tanh(arg) (nan,0) >./test-tanh-cc 5678 arg (5678,5678) sinh(arg) (-1.74513e+2465,-3.81804e+2465) cosh(arg) (-1.74513e+2465,-3.81804e+2465) s/c (1,-0) tanh(arg) (1,2.14543e-4932) >./text-tanh-cc 5679 arg (5679,5679) sinh(arg) (6.17015e+2465,-9.59925e+2465) cosh(arg) (6.17015e+2465,-9.59925e+2465) s/c (1,-0) tanh(arg) (nan,-0) > cat test-tanh.cc #include #include #include #include // atol using namespace std; int main(int argc, char **argv) { long mult; if (argc == 2) { mult = atol(argv[1]); } else { mult = 5L; } complex arg(1,1); arg *= mult; complex s,c,r,t; s=sinh(arg); c=cosh(arg); r=s/c; t=tanh(arg); cout << "libc version " << gnu_get_libc_version() << endl; cout << "arg " << arg << endl; cout << "sinh(arg) " << s << endl; cout << "cosh(arg) " << c << endl; cout << "s/c " << r << endl; cout << "tanh(arg) " << t << endl; return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43802
[Bug libstdc++/43802] Tanh Returns Incorrect Value
--- Comment #7 from tomdean at speakeasy dot org 2010-04-20 02:29 --- Subject: Re: Tanh Returns Incorrect Value On Tue, 2010-04-20 at 01:58 +, pinskia at gcc dot gnu dot org wrote: Thanks for clearing that up. Please close the bug report. I filed a bug with glibc. Thanks. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43802