All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H.S. Kim" <root@localhost.localdomain>
To: linuxppc-embedded@lists.linuxppc.org
Subject: Segmentation fault
Date: Fri, 6 Oct 2000 17:39:31 +0900	[thread overview]
Message-ID: <00100618093700.11698@localhost.localdomain> (raw)


fitst, I week the english.

On the MBX860 board..
and NFS file system.

1.
I compiled the binutil, gcc,  kernel and glibc without errors.
binutil-2.20.0.26
gcc-2.95.2
mpc8xx-2.2.13
glibc-2.1.3

2.
And, I compiled the ash shell.
ash-linux-0.2

3.
And, I compiled the modutils.
modutils-2.3.9

4.
1, 2, 3 -> no error compiled and install.
but, ./modutils-2.3.9/insmod/insmod.c (refer to follow source)
first, segmentation error
==========================================
              if ((p = strrchr(filename, '/')) != NULL){
                      p++;
                      }
              else{
                      p = filename;
              }
*** Result ***
p = strrchr(filename,'/')  -> segmentation fault
================================================
So, i maked strrchr function.
==========================================
                len = strlen(p);

printf("MAIN_04_01\n");
                p=filename;
                for(i=len;i>0;i--)
                        p++;

printf("MAIN_04_02\n");
                for(i=1;i<=len;i++)
                        if(*(--p) == '/' ) {
                                p++;
                                break;
                        }
printf("MAIN_04_03\n");
                if(i<len)
                        p = filename;
***  Result  ****
len = strlen(p)   -> segmentation fault
=======================================
So, I remake strlen function
=======================================
              i=0;
              p=filename;
printf("MAIN_04_011\n");
              while(flag) {
printf("MAIN_04_012\n");
                      if(*(p) == '\0') flag=0;
printf("MAIN_04_013\n");
                      p++;
printf("MAIN_04_014\n");
                      i++;
              }
              len=i;

*** Result ***
MAIN_04_011
MAIN_04_012
Segmentation fault
======================================

But, when I make the simple program, no segmentation fault
==================================================
main(){

char *filename="fissslename";

 char  *p;
 char  *p1;
 char  ch;
 int i;
 int len;

p=filename;
len=strlen(filename);
printf("length=%d\n",len);
i=0;
while(1)
{
        if( *(p) == '\0') {printf("same\n"); break;}
        p++;
        i++;
        printf("%s\n",p);
}
printf("%d\n",i);

p1=(char *)malloc(i);
p1=filename;
printf("%s\n",p1);
}
*** Result ***
length=11
issslename
ssslename
sslename
slename
lename
ename
name
ame
me
e

same
11
fissslename
===============================================

The simple program excuted no segmentation.
but, insmod.c failed.

insmod.c and simple program has the same emvironment compile system and library.

what wrong??

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

             reply	other threads:[~2000-10-06  8:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-06  8:39 H.S. Kim [this message]
2000-10-06 13:57 ` Segmentation fault Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2023-08-21 12:09 Michael John
2023-08-21 12:13 ` James Prestwood
2023-08-21 12:50   ` James Prestwood
2010-02-15  8:32 Marco Sarzi Madidini
2010-02-15  9:09 ` Frantisek Hanzlik
2009-08-06 11:51 Marko Saukko
2009-08-06 22:03 ` Denis Kenzior
2009-08-07  5:15   ` Marko Saukko
2009-08-08  1:15     ` Denis Kenzior
2004-12-20  5:56 segmentation fault ubberalles
2004-12-20  8:50 ` primero
2004-12-20 10:01   ` R. DuFresne
2004-04-06 18:08 Segmentation fault ppclinux
2003-02-24  9:55 Zealous
2003-01-27 17:31 segmentation fault Andrew Langdon-Davies
     [not found] <OF5DFD5B6D.7D47A4C9-ON65256B98.0022D8F5@pune.tcs.co.in>
2002-04-16 19:30 ` Segmentation fault Kurt Kehler
     [not found] <20020411084352.65e693fe.subscript@free.fr>
2002-04-16 19:30 ` Kurt Kehler
     [not found] <1328439575.20020411104849@kgpa.ru>
2002-04-16 19:29 ` Kurt Kehler
2001-12-05 13:52 Segmentation Fault Tom Beer
2000-08-10  6:52 Segmentation fault Li Guangdong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=00100618093700.11698@localhost.localdomain \
    --to=root@localhost.localdomain \
    --cc=linuxppc-embedded@lists.linuxppc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.