Code:
$ strace ./ex16
execve("./ex16", ["./ex16"], [/* 42 vars */]) = 0
brk(NULL) = 0x56223f2f4000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6c39e7c000
access("/etc/ld.so.preload", R_OK) = 0
open("/etc/ld.so.preload", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(3) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=115220, ...}) = 0
mmap(NULL, 115220, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f6c39e5f000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\3\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1689360, ...}) = 0
mmap(NULL, 3795360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f6c398bd000
mprotect(0x7f6c39a52000, 2097152, PROT_NONE) = 0
mmap(0x7f6c39c52000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x195000) = 0x7f6c39c52000
mmap(0x7f6c39c58000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f6c39c58000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f6c39e5d000
arch_prctl(ARCH_SET_FS, 0x7f6c39e5d700) = 0
mprotect(0x7f6c39c52000, 16384, PROT_READ) = 0
mprotect(0x56223db40000, 4096, PROT_READ) = 0
mprotect(0x7f6c39e7f000, 4096, PROT_READ) = 0
munmap(0x7f6c39e5f000, 115220) = 0
brk(NULL) = 0x56223f2f4000
brk(0x56223f315000) = 0x56223f315000
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
write(1, "Joe is at memory location 0x5622"..., 42Joe is at memory location 0x56223f2f4010:
) = 42
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x3f2f4030} ---
+++ killed by SIGSEGV +++
Segmentation fault
$ gdb ex16
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ex16...done.
(gdb) run
Starting program: /home/chaos/hive/projects/learn-c/lcthw/source/ex16
Joe is at memory location 0x555555756010:
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: No such file or directory.
$ valgrind ./ex16
==6234== Memcheck, a memory error detector
==6234== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==6234== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==6234== Command: ./ex16
==6234==
Joe is at memory location 0x51d7040:
Name: Joe Alex
Age: 32
Height: 64
Weight: 140
Frank is at memory location 0x51d70f0:
Name: Frank Blank
Age: 20
Height: 72
Weight: 180
Name: Joe Alex
Age: 52
Height: 66
Weight: 180
Name: Frank Blank
Age: 40
Height: 72
Weight: 200
==6234==
==6234== HEAP SUMMARY:
==6234== in use at exit: 0 bytes in 0 blocks
==6234== total heap usage: 5 allocs, 5 frees, 1,093 bytes allocated
==6234==
==6234== All heap blocks were freed -- no leaks are possible
==6234==
==6234== For counts of detected and suppressed errors, rerun with: -v
==6234== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)