RE: ELDK 3.0 C++ Problem

2 messages, 2 authors, 2004-05-21 · open the first message on its own page

RE: ELDK 3.0 C++ Problem

From: Wells, Charles <hidden>
Date: 2004-05-21 16:46:34

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/

Re: ELDK 3.0 C++ Problem

From: Mark Chambers <hidden>
Date: 2004-05-21 18:26:30

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/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help