* Re: segfault and gcc-2.96 [not found] ` <EzMw9.1438$hf.102567@castor.casema.net> @ 2002-11-04 23:32 ` JMK 2002-11-05 0:35 ` Ulrich Weigand 2002-11-05 0:35 ` Falk Hueffner 0 siblings, 2 replies; 5+ messages in thread From: JMK @ 2002-11-04 23:32 UTC (permalink / raw) Mark Swaanenburg wrote: > > "JMK" <jeffrey.m.klopotic@lmco.nospam.com> schreef in bericht > news:3DC324DA.4C495AEC@lmco.nospam.com... > > I was given a task to port a program written with Cygnus on an X86 box > > to a Suse Alpha. I am getting SEGMENTATION FAULTS also on code that > > works fine on the other computer. > > > > The existing code points to heavy use of stack vs heap memory and I've > > found a URL where someone details the porting issue that arises with > > such design. > > > > I'm trying to increase the heap size somehow, but can't find > > documentation on how to do it. I've got gcc version 2.95.2 20000220 > > (Debian GNU/Linux) compiler. I've read other material that says > > setting stack size can't be done. I'm hoping its not this compiler. > > > > Can it be done? If so, it could be the same problem you are facing and > > answer would benefit us both. > > > > Otherwise I need to go through my core dump. Tips on analyzing a core > > dump appreciated. > > I am also not very familiar with analyzing core dumps, but what I always do > is to start with a backtrace (bt). That shows you in which function the > segfault occured. It also displays the values of the arguments which were > passed to the functions. I hope this will give you something to start with. > > Mark > > > > > Jeff Mark, Thanks for getting back with me. When it crashed, (I have DDD to work with - a fairly good tool!) I did some returns and a back trace and it appears that it doesn't like // Global char *f1 = "default.str"; . . . { { char pfix[12] cin.getline(pfix,12,'\n'); ... strcpy (f1, pfix); <-------- Program received signal SIGSEGV, Segmentation fault. __stxcpy () at ../sysdeps/alpha/stxcpy.S:246 246 ../sysdeps/alpha/stxcpy.S: No such file or directory Current language\: auto; currently asm ... } } uname -a Linux xxx01 2.2.17 #1 Thu Jun 29 13:33:28 EDT 2000 alpha unknown gcc version 2.95.2 20000220 (Debian GNU/Linux) compiler The code was developed on a Cygnus equipped PC and is being ported to a Linux Alpha. I compiled with -Wall and the only error is a function that has a loop in it with no return -- warning control reaches end of non-void function 'func'. The portion it complains about never gets reached. Is there a way to tell if I'm choking the stack with memory demands on the Alpha v. the PC? Is there a known bug in __stxcpy? I checked the web, but if so, documentation isn't wasn't forthcoming. Any help appreciated, Jeff ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: segfault and gcc-2.96 2002-11-04 23:32 ` segfault and gcc-2.96 JMK @ 2002-11-05 0:35 ` Ulrich Weigand 2002-11-05 0:35 ` Falk Hueffner 1 sibling, 0 replies; 5+ messages in thread From: Ulrich Weigand @ 2002-11-05 0:35 UTC (permalink / raw) JMK <jeffrey.m.klopotic@lmco.nospam.com> writes: >// Global >char *f1 = "default.str"; > strcpy (f1, pfix); <-------- Program received signal SIGSEGV, You are trying to overwrite a string constant, which may reside in read-only memory. Thus the crash. You should fix your application to avoid doing that. As a workaround, you could also use the -fwritable-strings flag that tell gcc to allow writing to string "constants". -- Dr. Ulrich Weigand weigand@informatik.uni-erlangen.de ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: segfault and gcc-2.96 2002-11-04 23:32 ` segfault and gcc-2.96 JMK 2002-11-05 0:35 ` Ulrich Weigand @ 2002-11-05 0:35 ` Falk Hueffner 2002-11-05 7:31 ` Mark Swaanenburg 2002-11-06 4:40 ` Kevin Easton 1 sibling, 2 replies; 5+ messages in thread From: Falk Hueffner @ 2002-11-05 0:35 UTC (permalink / raw) JMK <jeffrey.m.klopotic@lmco.nospam.com> writes: > char *f1 = "default.str"; > ... > strcpy (f1, pfix); <-------- Program received signal SIGSEGV, String literals are not writable. They are of type const char*. -- Falk ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: segfault and gcc-2.96 2002-11-05 0:35 ` Falk Hueffner @ 2002-11-05 7:31 ` Mark Swaanenburg 2002-11-06 4:40 ` Kevin Easton 1 sibling, 0 replies; 5+ messages in thread From: Mark Swaanenburg @ 2002-11-05 7:31 UTC (permalink / raw) "Falk Hueffner" <falk.hueffner@student.uni-tuebingen.de> wrote in message news:878z08vonz.fsf@student.uni-tuebingen.de... > JMK <jeffrey.m.klopotic@lmco.nospam.com> writes: > > > char *f1 = "default.str"; > > ... > > strcpy (f1, pfix); <-------- Program received signal SIGSEGV, > > String literals are not writable. They are of type const char*. > > -- > Falk I would try it this way: char f1[ ] = {"default.str"}; I guess this would just create an 12 byte array which is writeable. Mark ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: segfault and gcc-2.96 2002-11-05 0:35 ` Falk Hueffner 2002-11-05 7:31 ` Mark Swaanenburg @ 2002-11-06 4:40 ` Kevin Easton 1 sibling, 0 replies; 5+ messages in thread From: Kevin Easton @ 2002-11-06 4:40 UTC (permalink / raw) In comp.os.linux.development.apps Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> wrote: > JMK <jeffrey.m.klopotic@lmco.nospam.com> writes: > >> char *f1 = "default.str"; >> ... >> strcpy (f1, pfix); <-------- Program received signal SIGSEGV, > > String literals are not writable. They are of type const char*. Actually for historical reasons, they're of type char *, but their contents are still not modifiable. - Kevin. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-11-06 4:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <apqobk$ocj$1@news.tudelft.nl>
[not found] ` <3DC324DA.4C495AEC@lmco.nospam.com>
[not found] ` <EzMw9.1438$hf.102567@castor.casema.net>
2002-11-04 23:32 ` segfault and gcc-2.96 JMK
2002-11-05 0:35 ` Ulrich Weigand
2002-11-05 0:35 ` Falk Hueffner
2002-11-05 7:31 ` Mark Swaanenburg
2002-11-06 4:40 ` Kevin Easton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox