Skip to content

Instantly share code, notes, and snippets.

@hdon
Created April 16, 2017 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hdon/3f96a8a6b67e078e0213660ec6245677 to your computer and use it in GitHub Desktop.
Save hdon/3f96a8a6b67e078e0213660ec6245677 to your computer and use it in GitHub Desktop.
bug-20170416
hdon@behemoth:~/src/git/bug-20170416$ cat foobarbaz.c
#include <stdlib.h>
#include <string.h>
typedef struct foo {
size_t *bar;
} foo;
int main(int argc, char **argv) {
foo baz;
for (size_t i=2; i<argc; i++)
baz.bar[i] = atoi(argv[i]);
return 0;
}
hdon@behemoth:~/src/git/bug-20170416$ gcc -g -gstabs+ -ggdb3 -o foobarbaz foobarbaz.c
hdon@behemoth:~/src/git/bug-20170416$ gdb ./foobarbaz
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
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 ./foobarbaz...done.
(gdb) set args foo bar baz
(gdb) start
Temporary breakpoint 1 at 0x400536: file foobarbaz.c, line 11.
Starting program: /home/hdon/src/git/bug-20170416/foobarbaz foo bar baz
Temporary breakpoint 1, main (argc=0, argv=0x400590 <__libc_csu_init>) at foobarbaz.c:11
11 for (size_t i=2; i<argc; i++)
(gdb) print argc
$1 = 0
(gdb) quit
A debugging session is active.
Inferior 1 [process 12972] will be killed.
Quit anyway? (y or n) y
hdon@behemoth:~/src/git/bug-20170416$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
hdon@behemoth:~/src/git/bug-20170416$ gdb --version
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
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".
hdon@behemoth:~/src/git/bug-20170416$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz
stepping : 10
microcode : 0xa0b
cpu MHz : 1998.000
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 4
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm
bugs :
bogomips : 5666.28
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz
stepping : 10
microcode : 0xa0b
cpu MHz : 1998.000
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 1
cpu cores : 4
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm
bugs :
bogomips : 5666.28
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 2
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz
stepping : 10
microcode : 0xa0b
cpu MHz : 1998.000
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 2
cpu cores : 4
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm
bugs :
bogomips : 5666.28
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
processor : 3
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz
stepping : 10
microcode : 0xa0b
cpu MHz : 1998.000
cache size : 6144 KB
physical id : 0
siblings : 4
core id : 3
cpu cores : 4
apicid : 3
initial apicid : 3
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm tpr_shadow vnmi flexpriority dtherm
bugs :
bogomips : 5666.28
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
hdon@behemoth:~/src/git/bug-20170416$ cat foobarbaz.c
#include <stdlib.h>
#include <string.h>
typedef struct foo {
size_t *bar;
} foo;
int main(int argc, char **argv) {
foo baz;
for (size_t i=2; i<argc; i++)
baz.bar[i] = atoi(argv[i]);
return 0;
}
hdon@behemoth:~/src/git/bug-20170416$
@hdon
Copy link
Author

hdon commented Apr 16, 2017

forgot info registers:

(gdb) i r
rax 0x400526 4195622
rbx 0x0 0
rcx 0x0 0
rdx 0x7fffffffd758 140737488344920
rsi 0x7fffffffd748 140737488344904
rdi 0x1 1
rbp 0x7fffffffd660 0x7fffffffd660
rsp 0x7fffffffd630 0x7fffffffd630
r8 0x400600 4195840
r9 0x7ffff7de78e0 140737351940320
r10 0x846 2118
r11 0x7ffff7a2e740 140737348036416
r12 0x400430 4195376
r13 0x7fffffffd740 140737488344896
r14 0x0 0
r15 0x0 0
rip 0x400536 0x400536 <main+16>
eflags 0x206 [ PF IF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment