char *a;

tanimi, hafiza'da sadece o pointer icin yer acar, onun isaret ettigi
array'i malloc/calloc ile allocate etmeniz lazim. Sizin durumunuzda
a'da NULL address var yani adres 0x0 ve siz o adrese birsey yazmaya
calisiyorsunuz ve ama dogal olarak o adrese yazma yetkiniz yok.


On Mon, Mar 22, 2004 at 10:45:22PM +0200, "?zkan KIRIK" wrote:
> Merhabalar,
> 
>     Bu sefer de cok ufak bir sorun icin sizleri rahatsiz ediyorum. freebsd ile 
> alakali degil ama...
> 
> programda (char *) tipi bir degiskenin NULL olup olmadigini bi yerde kontrol etmem 
> gerekiyor.
> ancak SEGMENTATION FAULT aliyorum. bunun nedenini incelemeye calistim.
> GNU DEBUGGERda olmasa napariz acaba :))
> 
> ben ilgili kodlari yazayim:
> 
> >>>>>>>>>>>>>
> Line154: char *client_sid;   /* acaba bir degeri olmayinca bellekte yer ayirmiyor mu 
> diye dusundum, degerini " "'a esitledim yine olmadi :) */
> ...
> Line222: query_string = strtop(tmp_str, "$\n");
> Line223: client_sid = strtok(NULL, "$\n");
> Line224:  if (*client_sid==NULL)
> Line225:        *client_sid='$';
> ...
> >>>>>>>>>>>>>
> 
> gdb ciktisinda bir nokta dikkatimi cekti :
> >> (gdb) display *client_sid
> >> 1: *client_sid = Error accessing memory address 0x0: Bad address.
> nedeni neden olabilir ki acaba?
> 
> 
> gdb ciktisi asagida:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> kitap# gdb ipfwadmin 16848
> GNU gdb 5.2.1 (FreeBSD)
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i386-undermydesk-freebsd"...
> Attaching to program: /usr/home/ryland/ogren_c/new_ipfwadmin/ipfwadmin, process 16848
> Reading symbols from /usr/lib/libc.so.5...done.
> Loaded symbols for /usr/lib/libc.so.5
> Reading symbols from /usr/libexec/ld-elf.so.1...done.
> Loaded symbols for /usr/libexec/ld-elf.so.1
> 0x280ba4c3 in accept () from /usr/lib/libc.so.5
> (gdb) break 224
> Breakpoint 1 at 0x804961e: file ipfwadmin.c, line 224.
> (gdb) continue
> Continuing.
> 
> Breakpoint 1, accept_request (client=5) at ipfwadmin.c:224
> 224      if (*client_sid==NULL)
> (gdb) display *client_sid
> 1: *client_sid = Error accessing memory address 0x0: Bad address.
> Disabling display 1 to avoid infinite recursion.
> (gdb) display client_sid
> 2: client_sid = 0x0
> (gdb) display &client_sid
> 3: &client_sid = (char **) 0xbfbfeacc
> (gdb) step
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x08049624 in accept_request (client=5) at ipfwadmin.c:224
> 224      if (*client_sid==NULL)
> 3: &client_sid = (char **) 0xbfbfeacc
> 2: client_sid = 0x0
> (gdb)
> 
> Program terminated with signal SIGSEGV, Segmentation fault.
> The program no longer exists.
> (gdb) q
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> 
> 
> Su ufak tefek sorunlari atlatabilirsem program bu gece bitecek :)
> 
> saygilar.tar.gz
> Ozkan KIRIK
> 

-- 
"When all else fails, read the instructions -- Murphy's Technology Laws"

Murat Balaban
http://www.enderunix.org

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Liste arsivi: http://lists.enderunix.org ve 
http://www.mail-archive.com/[EMAIL PROTECTED]
http://ipucu.EnderUNIX.org  - ihtiyac duyacaginiz kisa bilgiler bu sitede!


Cevap