public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* segmentation fault
@ 2005-05-20 23:45 Garritt Page
  0 siblings, 0 replies; 22+ messages in thread
From: Garritt Page @ 2005-05-20 23:45 UTC (permalink / raw)
  To: gcc-help

Good afternoon,
How do I remedy segmentation fault?
Thank you


		
Discover Yahoo! 
Use Yahoo! to plan a weekend, have fun online and more. Check it out! 
http://discover.yahoo.com/

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: Segmentation fault
  2010-03-25 11:45 Segmentation fault beamendsltd
  2010-03-25 13:18 ` James Tebneff
  2010-03-25 13:58 ` Andrew Haley
@ 2010-03-25 14:33 ` John (Eljay) Love-Jensen
  2 siblings, 0 replies; 22+ messages in thread
From: John (Eljay) Love-Jensen @ 2010-03-25 14:33 UTC (permalink / raw)
  To: beamendsltd, gcc-help

Hi Richard,

Segmentation faults are usually one of the easiest bugs to track down.  At least at the point of failure.

1. Compile your program with debug information:
# gcc -g -o MyApp MyCode.c

2. Run your program in the debugger:
# gdb ./MyApp
(gdb) run

3. When your program crashes, look at the stack backtrace:
(gdb) bt

The first few frames will give you the context of the crash, at the point of failure.

If the cause of the failure is distant in time/space from the point of failure, that can be trickier to figure out.

If the crash is hard to reproduce consistently, that may make things trickier to figure out.

For bug classification, here are some amusing (yet surprisingly useful) types of bugs:
http://en.wikipedia.org/wiki/Heisenbug

And here are some more, and a recap of the above:
http://catb.org/jargon/html/S/smash-the-stack.html
http://catb.org/jargon/html/B/buffer-overflow.html
http://catb.org/jargon/html/A/aliasing-bug.html
http://catb.org/jargon/html/F/fandango-on-core.html
http://catb.org/jargon/html/M/memory-leak.html
http://catb.org/jargon/html/M/memory-smash.html
http://catb.org/jargon/html/O/overrun-screw.html
http://catb.org/jargon/html/S/secondary-damage.html
http://catb.org/jargon/html/H/heisenbug.html
http://catb.org/jargon/html/B/Bohr-bug.html
http://catb.org/jargon/html/M/mandelbug.html
http://catb.org/jargon/html/S/schroedinbug.html

Sincerely,
--Eljay

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation fault
  2010-03-25 11:45 Segmentation fault beamendsltd
  2010-03-25 13:18 ` James Tebneff
@ 2010-03-25 13:58 ` Andrew Haley
  2010-03-25 14:33 ` John (Eljay) Love-Jensen
  2 siblings, 0 replies; 22+ messages in thread
From: Andrew Haley @ 2010-03-25 13:58 UTC (permalink / raw)
  To: gcc-help

On 03/25/2010 11:28 AM, beamendsltd wrote:

> I'm having a problem with a program in C that I wrote and have been
> using for some time. All of a sudden it has started crashing with a
> segmentation fault which I cannot track down.  Is the a way compiling in
> some sort extra run-time options that would give a better indication of
> what is causing the segmentation fault?

If you're running on a GNU/Linux system, use Valgrind's memory checker.

Andrew.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation fault
  2010-03-25 11:45 Segmentation fault beamendsltd
@ 2010-03-25 13:18 ` James Tebneff
  2010-03-25 13:58 ` Andrew Haley
  2010-03-25 14:33 ` John (Eljay) Love-Jensen
  2 siblings, 0 replies; 22+ messages in thread
From: James Tebneff @ 2010-03-25 13:18 UTC (permalink / raw)
  To: beamendsltd; +Cc: gcc-help

beamendsltd wrote:
> Hi All,
> I hope this is the right place for this....
>
> I'm having a problem with a program in C that I wrote and have been
> using for some time. All of a sudden it has started crashing with a
> segmentation fault which I cannot track down.  Is the a way compiling in
> some sort extra run-time options that would give a better indication of
> what is causing the segmentation fault?
>
> Thanks in advance!
>
> Cheers
> Richard
>
>   
-g -ggdb3

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Segmentation fault
@ 2010-03-25 11:45 beamendsltd
  2010-03-25 13:18 ` James Tebneff
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: beamendsltd @ 2010-03-25 11:45 UTC (permalink / raw)
  To: gcc-help

Hi All,
I hope this is the right place for this....

I'm having a problem with a program in C that I wrote and have been
using for some time. All of a sudden it has started crashing with a
segmentation fault which I cannot track down.  Is the a way compiling in
some sort extra run-time options that would give a better indication of
what is causing the segmentation fault?

Thanks in advance!

Cheers
Richard

-- 
I have become....... comfortably numb.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: segmentation fault
@ 2009-07-11  7:20 Bill McEnaney
  0 siblings, 0 replies; 22+ messages in thread
From: Bill McEnaney @ 2009-07-11  7:20 UTC (permalink / raw)
  To: anandulle, gcc-help

Hi Anandulle,

Sometimes segmentation faults happen when the computer tries to follow a
null pointer.  If you're running a C program that you've compiled with
gcc's C compiler, please show us that C program because it may help us
tell what's causing the segmentation fault.

Bill

> 
> hi,
>          I want to know why do we get segmentation faults in gcc for
just c
> compiler 
> 
> -- 
> View this message in context:
http://www.nabble.com/segmentation-fault-tp24437763p24437763.html
> Sent from the gcc - Help mailing list archive at Nabble.com.
> 
> 

________________________________________________________________
Please visit a saintly hero:
http://www.jakemoore.org

^ permalink raw reply	[flat|nested] 22+ messages in thread

* segmentation fault
@ 2009-07-11  6:55 anandulle
  0 siblings, 0 replies; 22+ messages in thread
From: anandulle @ 2009-07-11  6:55 UTC (permalink / raw)
  To: gcc-help


hi,
         I want to know why do we get segmentation faults in gcc for just c
compiler 

-- 
View this message in context: http://www.nabble.com/segmentation-fault-tp24437763p24437763.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: segmentation fault
  2007-06-05 15:53 ` Andrew Haley
@ 2007-06-05 15:56   ` Andrew Haley
  0 siblings, 0 replies; 22+ messages in thread
From: Andrew Haley @ 2007-06-05 15:56 UTC (permalink / raw)
  To: fred.cotton, gcc-help

Andrew Haley writes:
 > Redirected to gcc-help.
 > 
 > fred.cotton@oasincorp.com writes:
 >  > With apologies for being new:
 >  > In porting a hardware configuration from gcc-3.4.1 to gcc-4.2.0, I'm getting the
 >  > following error message:
 >  > 
 >  > In file included from /cygdrive/c/gcc-4.2.0/gcc/crtstuff.c:68:
 >  > /cygdrive/c/gcc-4.2.0/gcc/tsystem.h:53: internal compiler error: Segmentation
 >  > fault. 
 >  > 
 >  > Lines 52-54 of tsystem.h are:
 >  > 
 >  > #ifndef malloc
 >  > extern void *malloc (size_t);
 >  > #endif
 >  > 
 >  > If I remove these lines, all the other extern statements fail also. 
 >  > What precisely does Segmentation fault mean in this context? Is it referring to
 >  > the underlying Windows XP?
 >  > What sort of compiler, configuration or operating system parameters could be the
 >  > cause?
 >  > Where should I be looking?
 >  
 > Your gcc-4.2.0 is broken.  You need to look at exactly how it was
 > built.  Did you build it yourself from source?

Or, does this perhaps happen when you are building gcc-4.2.0 with gcc-3.4.1?

Andrew.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: segmentation fault
       [not found] <20070605114929.9oalrlftyfc0gwkg@webmail1.covadhosting.biz>
@ 2007-06-05 15:53 ` Andrew Haley
  2007-06-05 15:56   ` Andrew Haley
  0 siblings, 1 reply; 22+ messages in thread
From: Andrew Haley @ 2007-06-05 15:53 UTC (permalink / raw)
  To: fred.cotton; +Cc: gcc-help

Redirected to gcc-help.

fred.cotton@oasincorp.com writes:
 > With apologies for being new:
 > In porting a hardware configuration from gcc-3.4.1 to gcc-4.2.0, I'm getting the
 > following error message:
 > 
 > In file included from /cygdrive/c/gcc-4.2.0/gcc/crtstuff.c:68:
 > /cygdrive/c/gcc-4.2.0/gcc/tsystem.h:53: internal compiler error: Segmentation
 > fault. 
 > 
 > Lines 52-54 of tsystem.h are:
 > 
 > #ifndef malloc
 > extern void *malloc (size_t);
 > #endif
 > 
 > If I remove these lines, all the other extern statements fail also. 
 > What precisely does Segmentation fault mean in this context? Is it referring to
 > the underlying Windows XP?
 > What sort of compiler, configuration or operating system parameters could be the
 > cause?
 > Where should I be looking?
 
Your gcc-4.2.0 is broken.  You need to look at exactly how it was
built.  Did you build it yourself from source?

Andrew.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: segmentation fault
       [not found] <fc.3b9aca00bfe9273b3b9aca003b27e9bf.44e9e6d@reflex.at>
@ 2005-05-21  3:16 ` Antonio Coralles
  0 siblings, 0 replies; 22+ messages in thread
From: Antonio Coralles @ 2005-05-21  3:16 UTC (permalink / raw)
  To: gcc-help

Garritt Page wrote:

> Good afternoon,
> How do I remedy segmentation fault?
> Thank you
>
Maybe by writing bugfree code ?
No sorry: Allthough this is not a gcc question:
Compile your program with '-g' -> '$ gdb yourProg' -> type run -> triger
your sigsegv -> type 'back' and see where it happens. Then correct your
code and hope it works ...
antonio


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Segmentation fault
@ 2002-08-16 23:39 Lim Jiunn Bin
  0 siblings, 0 replies; 22+ messages in thread
From: Lim Jiunn Bin @ 2002-08-16 23:39 UTC (permalink / raw)
  To: gcc-help

Hi all,

I had compiled a C program under Soloris using gcc. But when I add a new 
source file, test.c, i will get a segmentation fault error.

The source code can compile with gcc, "gcc -o test.o test.c" without any 
problem. But if add the test.c to my Makefile, SSRCS variable and I 
compile my program with make. I will get a segmentation fault error 
after make try to link all object files. I had tried to debug the object 
file which is generate by the make command. I cannot access to a  
function in this object file (test.o) when i type "break function_name" 
in gdb. I get a message from gdb, " Cannot access memory at 0x8".  Why 
this situation happen?

If a the my new function to a existing file, then there will have no 
problem. Could anyone help me to solve this problem?

JB

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation Fault
  2001-09-15 12:51 Segmentation Fault Paulo J. Matos aka PDestroy
  2001-09-15 13:18 ` Paulo J. Matos aka PDestroy
@ 2001-09-28 16:33 ` Alexandre Oliva
  1 sibling, 0 replies; 22+ messages in thread
From: Alexandre Oliva @ 2001-09-28 16:33 UTC (permalink / raw)
  To: Paulo J. Matos aka PDestroy; +Cc: gcc-bugs, gcc-help

On Sep 15, 2001, pocm@rnl.ist.utl.pt (Paulo J. Matos aka PDestroy) wrote:

> # make bootstrap
> <supressing uninteresting lines>
> gcc -c  -DIN_GCC    -g  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -DHAVE_CONFIG_H    -I. -I. -I../../gcc-3.0.1/gcc -I../../gcc-3.0.1/gcc/. -I../../gcc-3.0.1/gcc/config -I../../gcc-3.0.1/gcc/../include ../../gcc-3.0.1/gcc/final.c -o final.o
> In file included from ../../gcc-3.0.1/gcc/system.h:85,
>                  from ../../gcc-3.0.1/gcc/final.c:48:
> ../../gcc-3.0.1/include/safe-ctype.h:1: Internal error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
> make[2]: *** [final.o] Error 1

Do you get the smae error if you `make bootstrap' again?  It seems
not, because bootstrap-lean does exactly the same, but gets you a
different error.  This is most often an indication of faulty
hardware.  Some people report this kind of error in cases of excessive
overclocking, broken memory, broken caches, etc.  Other than fixing
the broken hardware, sometimes disabling the L2 cache helps, with a
corresponding performance penalty.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation Fault
  2001-09-15 12:51 Segmentation Fault Paulo J. Matos aka PDestroy
@ 2001-09-15 13:18 ` Paulo J. Matos aka PDestroy
  2001-09-28 16:33 ` Alexandre Oliva
  1 sibling, 0 replies; 22+ messages in thread
From: Paulo J. Matos aka PDestroy @ 2001-09-15 13:18 UTC (permalink / raw)
  To: gcc-bugs; +Cc: gcc-help

Still desperate for not being able to compile GCC I tried a last option:

# make clean
# make CFLAGS='-O' LIBCFLAGS='-g -O2' LIBCXXFLAGS='-g -O2 -fno-implicit-templates' bootstrap
<supressing uninteresting lines>
gcc  -DIN_GCC    -g  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -DHAVE_CONFIG_H    -I. -I. -I../../gcc-3.0.1/gcc -I../../gcc-3.0.1/gcc/. -I../../gcc-3.0.1/gcc/config -I../../gcc-3.0.1/gcc/../include -c insn-attrtab.c
insn-attrtab.c: In function `pent_np_unit_blockage':
insn-attrtab.c:25365: Internal error: Illegal instruction
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
make[2]: *** [insn-attrtab.o] Error 1

:(
Something is wrong... is it me or what?

Best regards,
Paulo

pocm@rnl.ist.utl.pt (Paulo J. Matos aka PDestroy) writes:

> Hi,
> I've tried to compile GCC 3.0.1 (full distro), in an AMD K7 Athlon
> 700MHZ, 128MGS RAM, Linux RedHat OS!
> Consider that we have gcc-3.0.1.tar.gz in ~/ (home dir)
> I have currently GCC 3.0.0 installed!
> I've done the following:
> 
> # tar -xvzf gcc-3.0.1.tar.gz
> # mkdir gcc-objs
> # cd gcc-objs
> # ../gcc-3.0.1/configure
> Configuring for a i686-pc-linux-gnu host.
> Created "Makefile" in /home/pdestroy/gcc-objs using "mt-frag"
> Configuring libiberty...
> creating cache ../config.cache
> checking host system type... i686-pc-linux-gnu
> checking build system type... i686-pc-linux-gnu
> checking for ar... ar
> <rest of configure lines supressed>
> # make bootstrap
> <supressing uninteresting lines>
> gcc -c  -DIN_GCC    -g  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -DHAVE_CONFIG_H    -I. -I. -I../../gcc-3.0.1/gcc -I../../gcc-3.0.1/gcc/. -I../../gcc-3.0.1/gcc/config -I../../gcc-3.0.1/gcc/../include ../../gcc-3.0.1/gcc/final.c -o final.o
> In file included from ../../gcc-3.0.1/gcc/system.h:85,
>                  from ../../gcc-3.0.1/gcc/final.c:48:
> ../../gcc-3.0.1/include/safe-ctype.h:1: Internal error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
> make[2]: *** [final.o] Error 1
> 
> <desperately I tried the following>
> # make bootstrap-lean
> <supressing uninteresting lines>
> ./xgcc -B./ -B/usr/local/i686-pc-linux-gnu/bin/ -isystem /usr/local/i686-pc-linux-gnu/include -O2   -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -isystem ./include  -fPIC -g1  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I. -I../../gcc-3.0.1/gcc -I../../gcc-3.0.1/gcc/. -I../../gcc-3.0.1/gcc/config -I../../gcc-3.0.1/gcc/../include  -DL_ashrdi3 -c ../../gcc-3.0.1/gcc/libgcc2.c -o libgcc/./_ashrdi3.o
> In file included from /usr/include/_G_config.h:14,
>                  from /usr/include/libio.h:30,
>                  from include/stdio.h:73,
>                  from ../../gcc-3.0.1/gcc/tsystem.h:63,
>                  from ../../gcc-3.0.1/gcc/libgcc2.c:37:
> include/stddef.h:1: Internal error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
> make[3]: *** [libgcc/./_ashrdi3.o] Error 1
> 
> 
> Another segmentation fault... :(
> 
> Any ideas on this or this is really a bug?
> 
> Best regards,
> -- 
> Paulo J. Matos aka PDestroy : pocm@rnl.ist.utl.pt
> Instituto Superior Tecnico - Lisbon
> Computer Science and Software Eng. - AI
>  - > http://www.rnl.ist.utl.pt/~pocm
> 
> 

-- 
Paulo J. Matos aka PDestroy : pocm@rnl.ist.utl.pt
Instituto Superior Tecnico - Lisbon
Computer Science and Software Eng. - AI
 - > http://www.rnl.ist.utl.pt/~pocm

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Segmentation Fault
@ 2001-09-15 12:51 Paulo J. Matos aka PDestroy
  2001-09-15 13:18 ` Paulo J. Matos aka PDestroy
  2001-09-28 16:33 ` Alexandre Oliva
  0 siblings, 2 replies; 22+ messages in thread
From: Paulo J. Matos aka PDestroy @ 2001-09-15 12:51 UTC (permalink / raw)
  To: gcc-bugs, gcc-help

Hi,
I've tried to compile GCC 3.0.1 (full distro), in an AMD K7 Athlon
700MHZ, 128MGS RAM, Linux RedHat OS!
Consider that we have gcc-3.0.1.tar.gz in ~/ (home dir)
I have currently GCC 3.0.0 installed!
I've done the following:

# tar -xvzf gcc-3.0.1.tar.gz
# mkdir gcc-objs
# cd gcc-objs
# ../gcc-3.0.1/configure
Configuring for a i686-pc-linux-gnu host.
Created "Makefile" in /home/pdestroy/gcc-objs using "mt-frag"
Configuring libiberty...
creating cache ../config.cache
checking host system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu
checking for ar... ar
<rest of configure lines supressed>
# make bootstrap
<supressing uninteresting lines>
gcc -c  -DIN_GCC    -g  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long  -DHAVE_CONFIG_H    -I. -I. -I../../gcc-3.0.1/gcc -I../../gcc-3.0.1/gcc/. -I../../gcc-3.0.1/gcc/config -I../../gcc-3.0.1/gcc/../include ../../gcc-3.0.1/gcc/final.c -o final.o
In file included from ../../gcc-3.0.1/gcc/system.h:85,
                 from ../../gcc-3.0.1/gcc/final.c:48:
../../gcc-3.0.1/include/safe-ctype.h:1: Internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
make[2]: *** [final.o] Error 1

<desperately I tried the following>
# make bootstrap-lean
<supressing uninteresting lines>
./xgcc -B./ -B/usr/local/i686-pc-linux-gnu/bin/ -isystem /usr/local/i686-pc-linux-gnu/include -O2   -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -isystem ./include  -fPIC -g1  -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED  -I. -I. -I../../gcc-3.0.1/gcc -I../../gcc-3.0.1/gcc/. -I../../gcc-3.0.1/gcc/config -I../../gcc-3.0.1/gcc/../include  -DL_ashrdi3 -c ../../gcc-3.0.1/gcc/libgcc2.c -o libgcc/./_ashrdi3.o
In file included from /usr/include/_G_config.h:14,
                 from /usr/include/libio.h:30,
                 from include/stdio.h:73,
                 from ../../gcc-3.0.1/gcc/tsystem.h:63,
                 from ../../gcc-3.0.1/gcc/libgcc2.c:37:
include/stddef.h:1: Internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
make[3]: *** [libgcc/./_ashrdi3.o] Error 1


Another segmentation fault... :(

Any ideas on this or this is really a bug?

Best regards,
-- 
Paulo J. Matos aka PDestroy : pocm@rnl.ist.utl.pt
Instituto Superior Tecnico - Lisbon
Computer Science and Software Eng. - AI
 - > http://www.rnl.ist.utl.pt/~pocm

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: segmentation fault
  2000-05-28  8:45 segmentation fault wert ewrtert
@ 2000-05-28 14:52 ` Martin v. Loewis
  0 siblings, 0 replies; 22+ messages in thread
From: Martin v. Loewis @ 2000-05-28 14:52 UTC (permalink / raw)
  To: 0833; +Cc: gcc-help

> i've just installed glibc-2.1.3 and gcc-2.95.2. gcc works, but compiling:
[...]
> what is wrong here?

Most likely, you made an error in the installation procedure. Since
you did not give an indication what procedure you've used, and on what
operating system, it is hard to tell what you did wrong. There is also
a chance that you found an incompatibility between C libraries; in
this case, you'd need to reinstall gcc.

In any case, I strongly recommend to use prebuilt binaries.

Regards,
Martin

^ permalink raw reply	[flat|nested] 22+ messages in thread

* segmentation fault
@ 2000-05-28  8:45 wert ewrtert
  2000-05-28 14:52 ` Martin v. Loewis
  0 siblings, 1 reply; 22+ messages in thread
From: wert ewrtert @ 2000-05-28  8:45 UTC (permalink / raw)
  To: gcc-help

Hi all!

i've just installed glibc-2.1.3 and gcc-2.95.2. gcc works, but compiling:
 #include <iostream.h>
  int main(){
   cout << "geht nich!" << endl;
   return 0;
}
with g++ produces seg fault when it is run.

what is wrong here? Please help 
Thanks in Advance!

-- 
Sent through GMX FreeMail - http://www.gmx.net

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Segmentation fault
  1999-11-17  8:30 Segmentation fault Sarose
  1999-11-17 16:12 ` hwidjaja
@ 1999-11-30 23:28 ` Sarose
  1 sibling, 0 replies; 22+ messages in thread
From: Sarose @ 1999-11-30 23:28 UTC (permalink / raw)
  To: help-gcc

OS: Redhat Linux 5.2
GCC: gcc-2.7.2.3-14

Problem:

This is my program using insertstring function

I get Segmentation fault

#include <stdio.h>
#include <string.h>

char *insertstring (char *strbuf,char *chrstoins,int pos)
{
memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
((strbuf + pos))+1);
memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
return strbuf;
}
int main()
{
char *buffer;
char *test="<a href='index.html'>About Enet </a>";
char *test1="asdflaksdf";
buffer = insertstring(test,test1,1);
printf("%s",buffer);
return 0;
}

Compiling, Linking & OUTPUT
# gcc test1.c -o test
# ./test
Segmentation fault

I do suspect 'memmove' line of insertstring functions. But HOWTO fix it
still getting puzzle??

Hope I will get some help for your side.

--
Regards,
npguy



Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation fault
  1999-11-18  1:21   ` Sarose
@ 1999-11-30 23:28     ` Sarose
  0 siblings, 0 replies; 22+ messages in thread
From: Sarose @ 1999-11-30 23:28 UTC (permalink / raw)
  To: help-gcc

Thanks but I didn't get your answer properly. can u modify my function &
post it again.

Thanka again.


In article < 80vffq$lrp$1@nnrp1.deja.com >,
  hwidjaja@my-deja.com wrote:
> you have to do allocate enough memory of strbuff at insertstring()
> function.
> do malloc with new size is strlen(strbuff) + strbuff(chrstoins)
>
> hope this help.
> In article < 80u79j$o86$1@nnrp1.deja.com >,
>   Sarose <sarose@enet.com.np> wrote:
> > OS: Redhat Linux 5.2
> > GCC: gcc-2.7.2.3-14
> >
> > Problem:
> >
> > This is my program using insertstring function
> >
> > I get Segmentation fault
> >
> > #include <stdio.h>
> > #include <string.h>
> >
> > char *insertstring (char *strbuf,char *chrstoins,int pos)
> > {
> > memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
> > ((strbuf + pos))+1);
> > memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
> > return strbuf;
> > }
> > int main()
> > {
> > char *buffer;
> > char *test="<a href='index.html'>About Enet </a>";
> > char *test1="asdflaksdf";
> > buffer = insertstring(test,test1,1);
> > printf("%s",buffer);
> > return 0;
> > }
> >
> > Compiling, Linking & OUTPUT
> > # gcc test1.c -o test
> > # ./test
> > Segmentation fault
> >
> > I do suspect 'memmove' line of insertstring functions. But HOWTO fix
> it
> > still getting puzzle??
> >
> > Hope I will get some help for your side.
> >
> > --
> > Regards,
> > npguy
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

--
Regards,
npguy


Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation fault
  1999-11-17 16:12 ` hwidjaja
  1999-11-18  1:21   ` Sarose
@ 1999-11-30 23:28   ` hwidjaja
  1 sibling, 0 replies; 22+ messages in thread
From: hwidjaja @ 1999-11-30 23:28 UTC (permalink / raw)
  To: help-gcc

you have to do allocate enough memory of strbuff at insertstring()
function.
do malloc with new size is strlen(strbuff) + strbuff(chrstoins)

hope this help.
In article < 80u79j$o86$1@nnrp1.deja.com >,
  Sarose <sarose@enet.com.np> wrote:
> OS: Redhat Linux 5.2
> GCC: gcc-2.7.2.3-14
>
> Problem:
>
> This is my program using insertstring function
>
> I get Segmentation fault
>
> #include <stdio.h>
> #include <string.h>
>
> char *insertstring (char *strbuf,char *chrstoins,int pos)
> {
> memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
> ((strbuf + pos))+1);
> memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
> return strbuf;
> }
> int main()
> {
> char *buffer;
> char *test="<a href='index.html'>About Enet </a>";
> char *test1="asdflaksdf";
> buffer = insertstring(test,test1,1);
> printf("%s",buffer);
> return 0;
> }
>
> Compiling, Linking & OUTPUT
> # gcc test1.c -o test
> # ./test
> Segmentation fault
>
> I do suspect 'memmove' line of insertstring functions. But HOWTO fix
it
> still getting puzzle??
>
> Hope I will get some help for your side.
>
> --
> Regards,
> npguy
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation fault
  1999-11-17 16:12 ` hwidjaja
@ 1999-11-18  1:21   ` Sarose
  1999-11-30 23:28     ` Sarose
  1999-11-30 23:28   ` hwidjaja
  1 sibling, 1 reply; 22+ messages in thread
From: Sarose @ 1999-11-18  1:21 UTC (permalink / raw)
  To: help-gcc

Thanks but I didn't get your answer properly. can u modify my function &
post it again.

Thanka again.


In article < 80vffq$lrp$1@nnrp1.deja.com >,
  hwidjaja@my-deja.com wrote:
> you have to do allocate enough memory of strbuff at insertstring()
> function.
> do malloc with new size is strlen(strbuff) + strbuff(chrstoins)
>
> hope this help.
> In article < 80u79j$o86$1@nnrp1.deja.com >,
>   Sarose <sarose@enet.com.np> wrote:
> > OS: Redhat Linux 5.2
> > GCC: gcc-2.7.2.3-14
> >
> > Problem:
> >
> > This is my program using insertstring function
> >
> > I get Segmentation fault
> >
> > #include <stdio.h>
> > #include <string.h>
> >
> > char *insertstring (char *strbuf,char *chrstoins,int pos)
> > {
> > memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
> > ((strbuf + pos))+1);
> > memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
> > return strbuf;
> > }
> > int main()
> > {
> > char *buffer;
> > char *test="<a href='index.html'>About Enet </a>";
> > char *test1="asdflaksdf";
> > buffer = insertstring(test,test1,1);
> > printf("%s",buffer);
> > return 0;
> > }
> >
> > Compiling, Linking & OUTPUT
> > # gcc test1.c -o test
> > # ./test
> > Segmentation fault
> >
> > I do suspect 'memmove' line of insertstring functions. But HOWTO fix
> it
> > still getting puzzle??
> >
> > Hope I will get some help for your side.
> >
> > --
> > Regards,
> > npguy
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

--
Regards,
npguy


Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Segmentation fault
  1999-11-17  8:30 Segmentation fault Sarose
@ 1999-11-17 16:12 ` hwidjaja
  1999-11-18  1:21   ` Sarose
  1999-11-30 23:28   ` hwidjaja
  1999-11-30 23:28 ` Sarose
  1 sibling, 2 replies; 22+ messages in thread
From: hwidjaja @ 1999-11-17 16:12 UTC (permalink / raw)
  To: help-gcc

you have to do allocate enough memory of strbuff at insertstring()
function.
do malloc with new size is strlen(strbuff) + strbuff(chrstoins)

hope this help.
In article < 80u79j$o86$1@nnrp1.deja.com >,
  Sarose <sarose@enet.com.np> wrote:
> OS: Redhat Linux 5.2
> GCC: gcc-2.7.2.3-14
>
> Problem:
>
> This is my program using insertstring function
>
> I get Segmentation fault
>
> #include <stdio.h>
> #include <string.h>
>
> char *insertstring (char *strbuf,char *chrstoins,int pos)
> {
> memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
> ((strbuf + pos))+1);
> memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
> return strbuf;
> }
> int main()
> {
> char *buffer;
> char *test="<a href='index.html'>About Enet </a>";
> char *test1="asdflaksdf";
> buffer = insertstring(test,test1,1);
> printf("%s",buffer);
> return 0;
> }
>
> Compiling, Linking & OUTPUT
> # gcc test1.c -o test
> # ./test
> Segmentation fault
>
> I do suspect 'memmove' line of insertstring functions. But HOWTO fix
it
> still getting puzzle??
>
> Hope I will get some help for your side.
>
> --
> Regards,
> npguy
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Segmentation fault
@ 1999-11-17  8:30 Sarose
  1999-11-17 16:12 ` hwidjaja
  1999-11-30 23:28 ` Sarose
  0 siblings, 2 replies; 22+ messages in thread
From: Sarose @ 1999-11-17  8:30 UTC (permalink / raw)
  To: help-gcc

OS: Redhat Linux 5.2
GCC: gcc-2.7.2.3-14

Problem:

This is my program using insertstring function

I get Segmentation fault

#include <stdio.h>
#include <string.h>

char *insertstring (char *strbuf,char *chrstoins,int pos)
{
memmove ((strbuf + pos)+ strlen (chrstoins),(strbuf + pos), strlen
((strbuf + pos))+1);
memcpy ((strbuf + pos), chrstoins, strlen (chrstoins));
return strbuf;
}
int main()
{
char *buffer;
char *test="<a href='index.html'>About Enet </a>";
char *test1="asdflaksdf";
buffer = insertstring(test,test1,1);
printf("%s",buffer);
return 0;
}

Compiling, Linking & OUTPUT
# gcc test1.c -o test
# ./test
Segmentation fault

I do suspect 'memmove' line of insertstring functions. But HOWTO fix it
still getting puzzle??

Hope I will get some help for your side.

--
Regards,
npguy



Sent via Deja.com http://www.deja.com/
Before you buy.

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2010-03-25 11:45 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-20 23:45 segmentation fault Garritt Page
  -- strict thread matches above, loose matches on Subject: below --
2010-03-25 11:45 Segmentation fault beamendsltd
2010-03-25 13:18 ` James Tebneff
2010-03-25 13:58 ` Andrew Haley
2010-03-25 14:33 ` John (Eljay) Love-Jensen
2009-07-11  7:20 segmentation fault Bill McEnaney
2009-07-11  6:55 anandulle
     [not found] <20070605114929.9oalrlftyfc0gwkg@webmail1.covadhosting.biz>
2007-06-05 15:53 ` Andrew Haley
2007-06-05 15:56   ` Andrew Haley
     [not found] <fc.3b9aca00bfe9273b3b9aca003b27e9bf.44e9e6d@reflex.at>
2005-05-21  3:16 ` Antonio Coralles
2002-08-16 23:39 Segmentation fault Lim Jiunn Bin
2001-09-15 12:51 Segmentation Fault Paulo J. Matos aka PDestroy
2001-09-15 13:18 ` Paulo J. Matos aka PDestroy
2001-09-28 16:33 ` Alexandre Oliva
2000-05-28  8:45 segmentation fault wert ewrtert
2000-05-28 14:52 ` Martin v. Loewis
1999-11-17  8:30 Segmentation fault Sarose
1999-11-17 16:12 ` hwidjaja
1999-11-18  1:21   ` Sarose
1999-11-30 23:28     ` Sarose
1999-11-30 23:28   ` hwidjaja
1999-11-30 23:28 ` Sarose

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 read-only IMAP folder(s) and NNTP newsgroup(s).