int AddVariableToNewType
(
char variablename_var[], // Variablenname
char datatype_var[] // Datentyp der Variable
)
{
if (newtypelistend_var->variabledef==NULL)
{
// Variablenliste ist leer
newtypelistend_var->variabledef=(variabledata_struct *)
malloc(sizeof(variabledata_struct)); <=========
if (newtypelistend_var->variabledef==NULL)
return 1;
newtypevariablelistend_var=newtypelistend_var->variabledef;
}
else
{
// es sind Eintraege vorhanden
newtypevariablelistend_var->next=(variabledata_struct*)
malloc(sizeof(variabledata_struct));
if (newtypevariablelistend_var->next==NULL)
return 1;
newtypevariablelistend_var=newtypevariablelistend_var->next;
}
strcpy(newtypevariablelistend_var->name,variablename_var);
strcpy(newtypevariablelistend_var->datatype,datatype_var);
newtypevariablelistend_var->next=NULL;
return 0;
}
I suspect the problem lies within libc6 but I did not find any bug
reports stating a problem with malloc() resp. mallopt(). So if anyone
had an idea what my problem was and how I could probably fix it, I would
be very grateful for any hint.
I'm not quite sure if this is the right newsgroup to post to, so if this
is the worng newsgroup I apologize and will be thankful if you could tell
me the correct one.
Thank you for reading!
With best regards,
Andreas
At least in my personal experience 100% of all cases of a segfault somewhere
in the innards of malloc() are due to some previous memory corruption. Since
malloc() and friends are probably one of the most-used parts of libc your
chances of having found a bug are extremely small, so before you even start
suspecting a bug in the libc you really should make 100% sure it's not due
to memory corruption somewhere else in your program (which one can't figure
out from the snippet you posted - the worst thing about memory corruption is
that it often becomes a problem only at places that seem to be completely
unrelated). And just because it seemed to work on a different machine does
not proof anything, you were just unlucky that it didn't also fail on the
other machine with a different malloc implementation - I had a program that
I had written on a DEC machine work for years and only segfault when trying
to run it on Linux because of a bug that just didn't show up on the DEC
machine.
Sorry for the bad news, Jens
--
_ _____ _____
| ||_ _||_ _| Jens.T...@physik.fu-berlin.de
_ | | | | | |
| |_| | | | | | http://www.physik.fu-berlin.de/~toerring
\___/ens|_|homs|_|oerring
> Andreas Lagemann <a...@informatik.tu-cottbus.de> wrote:
> > The problem is that mallopt() from libc.so.6 (called by
> > malloc()) causes SEGFAULT.
> At least in my personal experience 100% of all cases of a segfault somewhere
> in the innards of malloc() are due to some previous memory corruption. Since
May I add that valgrind will probably lead Andreas straight to
the problem. Other tools that may help are ccmalloc, dmalloc,
efence and mpatrol (all free), as well as Chaperon and Insure++ ($$)
Cheers,
--
In order to understand recursion you must first understand recursion.
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#SIGSEGV
--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:aaa...@daimi.au.dk
char *mybuf[1==1]; (2==3)[mybuf]="Hello World!";