* RE: ELDK 3.0 C++ Problem
@ 2004-05-21 16:46 Wells, Charles
2004-05-21 18:26 ` Mark Chambers
0 siblings, 1 reply; 8+ messages in thread
From: Wells, Charles @ 2004-05-21 16:46 UTC (permalink / raw)
To: 'Carlo Parravicini'; +Cc: linuxppc-embedded
Carlo.
> Lost the beer, the code is wrong but the segfaulted is in the "new"
> (checked with a printf before the memset & also with gdb eh eh)
I'll bet _two_ cases of beer that Wolfgang won the beer. The seg. fault is
happening in the memset.
"printf before the memset" is the wrong debugging tool to use here because
the segment fault happens _before_ the printf output gets printed. Why gdb
didn't show that you got to the memset call is a puzzle.
One thing is sure. Your program allocates 4 bytes on the heap. It then
clears those 4 bytes and the 9,996 bytes that follow. That's _guaranteed_
to mess up the heap.
BTW, give your program a try in Developer Studio on your PC. You get a
segment fault out of memset.
Regards,
Charlie
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: ELDK 3.0 C++ Problem
2004-05-21 16:46 ELDK 3.0 C++ Problem Wells, Charles
@ 2004-05-21 18:26 ` Mark Chambers
0 siblings, 0 replies; 8+ messages in thread
From: Mark Chambers @ 2004-05-21 18:26 UTC (permalink / raw)
To: 'Carlo Parravicini'; +Cc: linuxppc-embedded
> I'll bet _two_ cases of beer that Wolfgang won the beer. The seg. fault is
> happening in the memset.
>
Before this goes any further, I think we need to put the beer in escrow. I
humbly offer my garage. I will sample it and make sure it's worthy of this
duel.
By the way - on the printf - do you have a '\n' on the end of your
diagnostic message? If you're right, you're going to have to go the next
step and find out exactly what is failing in new(). 'new' should basically
boil down to malloc(4), possibly followed by 'if (p == 0) branch_to_catch',
then *p = 10000; Hard to imagine what could go wrong there...
Mark Chambers
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: ELDK 3.0 C++ Problem
@ 2004-05-19 21:38 Gosha, Michael (Michael)
2004-05-19 23:17 ` Wolfgang Denk
0 siblings, 1 reply; 8+ messages in thread
From: Gosha, Michael (Michael) @ 2004-05-19 21:38 UTC (permalink / raw)
To: linuxppc-embedded; +Cc: Carlo Parravicini
The problem is with your statement, "new int (1000)". This should be
"new int [1000]". You are telling the compiler to initialize 1 integer
to 1000 instead of allocating 1000 integers. Replace the parens with
brackets and it should work.
Regards,
Michael Gosha
-----Original Message-----
From: owner-linuxppc-embedded@lists.linuxppc.org
[mailto:owner-linuxppc-embedded@lists.linuxppc.org] On Behalf Of
Wolfgang Denk
Sent: Wednesday, May 19, 2004 12:57 PM
To: Carlo Parravicini
Cc: linuxppc-embedded@lists.linuxppc.org
Subject: Re: ELDK 3.0 C++ Problem
In message <200405191757.48552.c.parravicini@sehitaly.com> you wrote:
>
> have anybody problems using ELDK3.0 ppc_8xx-g++ cross-compiler(x86) on
> 'new' function?
What makes you think this is a problem with ELDK's C++ compiler? Did
you for example try to compile the same program with a native GCC 3.x
C++ compiler on your PC?
> I try to run a stupid program like that on a linux 2.4.4 (previus ELDK
> 2.1) & linux 2.4.24 (ELDK 3.0)
I agree with your rating ;-)
> //=================================================
> #include <iostream>
> #include <string.h>
> int main (int argc, char **argv)
> {
> int *p = new int (10000);
> memset ( p, 0, 10000);
> if (p == NULL)
> std::cout << "Allocation error\n";
> else
> std::cout << "OK.\n";
>
> return 0;
> //=================================================
This program cannot be compiled, there is a '}' missing.
> ppc_8xx-g++ =Wall cpp.cpp -o cpp
This was most definitely NOT the command line you used.
> Both give me a segmentation fault on 'new' execution
What makes you think so? I bet a case of beer that the 'new" returned
just fine, and that your program segfaulted in memset() instead.
Of course you didn't see this, as your test if p is NULL is much too
late, and obviously you didn't bother to run the program under a
debugger.
> Any other have c++ compiling problems or have compiled c++ code
> successfuly?
There are no known C++ problems specific to the ELDK (i. e. except
those that apply to the native version of the same GCC as well).
The problem is not with the ELDK.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
Nail here --X-- for new monitor.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ELDK 3.0 C++ Problem
2004-05-19 21:38 Gosha, Michael (Michael)
@ 2004-05-19 23:17 ` Wolfgang Denk
0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2004-05-19 23:17 UTC (permalink / raw)
To: linuxppc-embedded
In message <6F45E974A11B294383FD819C76719D8701984F@txex2ku01>
Carlo Parravicini wrote:
>
> The problem is with your statement, "new int (1000)". This should be
> "new int [1000]". You are telling the compiler to initialize 1 integer
> to 1000 instead of allocating 1000 integers. Replace the parens with
> brackets and it should work.
Yes, this was one of the problems with his code.
Anotrher is that the length in the memset() is probably wrong:
> > int *p = new int (10000);
> > memset ( p, 0, 10000);
This clears only a small part of the (wanted?) array.
The whole code looks broken.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
Our OS who art in CPU, UNIX be thy name.
Thy programs run, thy syscalls done,
In kernel as it is in user!
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* ELDK 3.0 C++ Problem
@ 2004-05-19 15:57 Carlo Parravicini
2004-05-19 17:56 ` Wolfgang Denk
0 siblings, 1 reply; 8+ messages in thread
From: Carlo Parravicini @ 2004-05-19 15:57 UTC (permalink / raw)
To: linuxppc-embedded@lists.linuxppc.org
Hi all,
have anybody problems using ELDK3.0 ppc_8xx-g++ cross-compiler(x86) on 'new'
function?
I try to run a stupid program like that on a linux 2.4.4 (previus ELDK 2.1) &
linux 2.4.24 (ELDK 3.0)
//=================================================
#include <iostream>
#include <string.h>
int main (int argc, char **argv)
{
int *p = new int (10000);
memset ( p, 0, 10000);
if (p == NULL)
std::cout << "Allocation error\n";
else
std::cout << "OK.\n";
return 0;
//=================================================
ppc_8xx-g++ =Wall cpp.cpp -o cpp
ldd cpp->
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x0ff12000)
libm.so.6 => /lib/libm.so.6 (0x0fe46000)
libc.so.6 => /lib/libc.so.6 (0x0fce7000)
/lib/ld.so.1 => /lib/ld.so.1 (0x30000000)
Both give me a segmentation fault on 'new' execution
The same using a malloc compiled in 'C' mode runs
Previous version of ELDK works fine
Any other have c++ compiling problems or have compiled c++ code successfuly?
email: carlo@sehitaly.com
http://www.sehitaly.com
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ELDK 3.0 C++ Problem
2004-05-19 15:57 Carlo Parravicini
@ 2004-05-19 17:56 ` Wolfgang Denk
2004-05-20 14:02 ` Carlo Parravicini
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Denk @ 2004-05-19 17:56 UTC (permalink / raw)
To: Carlo Parravicini; +Cc: linuxppc-embedded@lists.linuxppc.org
In message <200405191757.48552.c.parravicini@sehitaly.com> you wrote:
>
> have anybody problems using ELDK3.0 ppc_8xx-g++ cross-compiler(x86) on 'new'
> function?
What makes you think this is a problem with ELDK's C++ compiler? Did
you for example try to compile the same program with a native GCC 3.x
C++ compiler on your PC?
> I try to run a stupid program like that on a linux 2.4.4 (previus ELDK 2.1) &
> linux 2.4.24 (ELDK 3.0)
I agree with your rating ;-)
> //=================================================
> #include <iostream>
> #include <string.h>
> int main (int argc, char **argv)
> {
> int *p = new int (10000);
> memset ( p, 0, 10000);
> if (p == NULL)
> std::cout << "Allocation error\n";
> else
> std::cout << "OK.\n";
>
> return 0;
> //=================================================
This program cannot be compiled, there is a '}' missing.
> ppc_8xx-g++ =Wall cpp.cpp -o cpp
This was most definitely NOT the command line you used.
> Both give me a segmentation fault on 'new' execution
What makes you think so? I bet a case of beer that the 'new" returned
just fine, and that your program segfaulted in memset() instead.
Of course you didn't see this, as your test if p is NULL is much too
late, and obviously you didn't bother to run the program under a
debugger.
> Any other have c++ compiling problems or have compiled c++ code successfuly?
There are no known C++ problems specific to the ELDK (i. e. except
those that apply to the native version of the same GCC as well).
The problem is not with the ELDK.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
Nail here --X-- for new monitor.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ELDK 3.0 C++ Problem
2004-05-19 17:56 ` Wolfgang Denk
@ 2004-05-20 14:02 ` Carlo Parravicini
2004-05-20 16:14 ` Wolfgang Denk
0 siblings, 1 reply; 8+ messages in thread
From: Carlo Parravicini @ 2004-05-20 14:02 UTC (permalink / raw)
To: linuxppc-embedded@lists.linuxppc.org
Alle 19:56, mercoledì 19 maggio 2004, Wolfgang Denk ha scritto:
> In message <200405191757.48552.c.parravicini@sehitaly.com> you wrote:
> > have anybody problems using ELDK3.0 ppc_8xx-g++ cross-compiler(x86) on
> > 'new' function?
>
> What makes you think this is a problem with ELDK's C++ compiler? Did
> you for example try to compile the same program with a native GCC 3.x
> C++ compiler on your PC?
Yes, I arrive to this point only because we have a problem in wxWindows:
We have a project where we build:
-- X (tiny) (cross compiled)
-- glib (compiled native)
-- gtk (compiled native)
-- wxGTK (cross compiled)
-- minimal sample (wx-based)
for ppc system (ELDK 2.1) & x86 all works fine
On ELDK 3.0 (recompiling all as above) all works (X and gtk tests) but not
wxGTK (also with wx samples) and because this is the only package build in
cpp this is why I was think to the cpp compiling.
In effect the test below is broken, written whit the [] runs.
So the question change: does anybody try to compile and use wxGTK with
ELDK3.0 ??
>
> > I try to run a stupid program like that on a linux 2.4.4 (previus ELDK
> > 2.1) & linux 2.4.24 (ELDK 3.0)
>
> I agree with your rating ;-)
Also me
>
> > //=================================================
> > #include <iostream>
> > #include <string.h>
> > int main (int argc, char **argv)
> > {
> > int *p = new int (10000);
> > memset ( p, 0, 10000);
> > if (p == NULL)
> > std::cout << "Allocation error\n";
> > else
> > std::cout << "OK.\n";
> >
> > return 0;
> > //=================================================
>
> This program cannot be compiled, there is a '}' missing.
>
> > ppc_8xx-g++ =Wall cpp.cpp -o cpp
>
> This was most definitely NOT the command line you used.
>
> > Both give me a segmentation fault on 'new' execution
>
> What makes you think so? I bet a case of beer that the 'new" returned
> just fine, and that your program segfaulted in memset() instead.
Lost the beer, the code is wrong but the segfaulted is in the "new"
(checked with a printf before the memset & also with gdb eh eh)
>
> Of course you didn't see this, as your test if p is NULL is much too
> late, and obviously you didn't bother to run the program under a
> debugger.
>
> > Any other have c++ compiling problems or have compiled c++ code
> > successfuly?
>
> There are no known C++ problems specific to the ELDK (i. e. except
> those that apply to the native version of the same GCC as well).
>
> The problem is not with the ELDK.
>
> Best regards,
>
> Wolfgang Denk
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: ELDK 3.0 C++ Problem
2004-05-20 14:02 ` Carlo Parravicini
@ 2004-05-20 16:14 ` Wolfgang Denk
0 siblings, 0 replies; 8+ messages in thread
From: Wolfgang Denk @ 2004-05-20 16:14 UTC (permalink / raw)
To: Carlo Parravicini; +Cc: linuxppc-embedded@lists.linuxppc.org
In message <200405201602.44480.c.parravicini@sehitaly.com> you wrote:
>
> > What makes you think so? I bet a case of beer that the 'new" returned
> > just fine, and that your program segfaulted in memset() instead.
>
> Lost the beer, the code is wrong but the segfaulted is in the "new"
> (checked with a printf before the memset & also with gdb eh eh)
No. The new returns just fine in my test. The segfault happens in the
memset() call when you write to memory that you don't own. I tested
it.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
The Buddha, the Godhead, resides quite as comfortably in the circuits
of a digital computer or the gears of a cycle transmission as he does
at the top of a mountain or in the petals of a flower.
- R. Pirsig, "Zen and the Art of Motorcycle Maintenance"
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-05-21 18:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-21 16:46 ELDK 3.0 C++ Problem Wells, Charles
2004-05-21 18:26 ` Mark Chambers
-- strict thread matches above, loose matches on Subject: below --
2004-05-19 21:38 Gosha, Michael (Michael)
2004-05-19 23:17 ` Wolfgang Denk
2004-05-19 15:57 Carlo Parravicini
2004-05-19 17:56 ` Wolfgang Denk
2004-05-20 14:02 ` Carlo Parravicini
2004-05-20 16:14 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).