# libc core dump



## cgigeek (Nov 13, 2013)

```
gdb finfo
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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 "amd64-marcel-freebsd"...(no debugging symbols found)...
(gdb) run /etc/rc.conf   
Starting program: /usr/local/bin/finfo /etc/rc.conf
(no debugging symbols found)...(no debugging symbols found)...File  : /etc/rc.conf
Type  : Regular File
Inode : 23739
Modes : rw-r--r-- 
Links : 1
Size  : 657 Bytes (0.64K) (0.00M)
Blocks: 4
Mt Ma : 000
Mt Mi : 0x0000005a
IO BS : 16384

Program received signal SIGSEGV, Segmentation fault.
0x0000000800838d87 in strlen () from /lib/libc.so.7
```



```
8.4-RELEASE-p3 FreeBSD 8.4-RELEASE-p3 #0 r255342 (amd64)
```


Thanks in advance.


----------



## kpa (Nov 13, 2013)

Compile the application with WITH_DEBUG:

`make -C /usr/ports/sysutils/finfo -D WITH_DEBUG clean install`

Then run the compiled program in gdb(1) as you already did.

Get a backtrace from the crashed program:


```
(gdb) bt
```

A crash in strlen(3) is almost certainly a problem earlier in the program before the function gets called. It simply looks for the next null byte starting from the address it is given so the only way it to cause a crash is to try to read a memory address that has no memory mapped in the process' memory map. This happens if strlen(3) gets passed an invalid pointer.


----------



## cgigeek (Nov 13, 2013)

```
gdb finfo
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 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 "amd64-marcel-freebsd"...
(gdb) run /etc/rc.conf
Starting program: /usr/local/bin/finfo /etc/rc.conf
File  : /etc/rc.conf
Type  : Regular File
Inode : 23739
Modes : rw-r--r-- 
Links : 1
Size  : 657 Bytes (0.64K) (0.00M)
Blocks: 4
Mt Ma : 000
Mt Mi : 0x0000005a
IO BS : 16384

Program received signal SIGSEGV, Segmentation fault.
0x0000000800838d87 in strlen () from /lib/libc.so.7
(gdb) bt
#0  0x0000000800838d87 in strlen () from /lib/libc.so.7
#1  0x00000008008319e2 in open () from /lib/libc.so.7
#2  0x0000000800832b3a in vfprintf () from /lib/libc.so.7
#3  0x000000080082093a in printf () from /lib/libc.so.7
#4  0x0000000000400d48 in main (argc=2, argv=0x7fffffffeaf0) at finfo.c:47
```



			
				kpa said:
			
		

> Compile the application with WITH_DEBUG:
> 
> `make -C /usr/ports/sysutils/finfo -D WITH_DEBUG clean install`
> 
> ...


----------

