SlideShare una empresa de Scribd logo
1 de 38
Descargar para leer sin conexión
SIGSEGV
Sune Vuorela
Debugging | København | Oktober 2013
Ego - job

2013-10-26

sune.vuorela.dk

2
Ego

2013-10-26

sune.vuorela.dk

3
Ego
●

C++

●

KDevelop

●

Java

●

Gdb

●

Shell

●

Valgrind

●

Make

●

Git

●

C#

●

Eclipse

2013-10-26

sune.vuorela.dk

4
SIGSEGV
●

$ ./kode

●

Segmentation fault

●

2013-10-26

sune.vuorela.dk

5
SIGSEGV

2013-10-26

sune.vuorela.dk

6
App

2013-10-26

sune.vuorela.dk

7
App
●
●

git://anongit.kde.org/scratch/sune/sigsegv.git
http://quickgit.kde.org/?
p=scratch/sune/sigsegv.git

●

2013-10-26

sune.vuorela.dk

8
Få fat i backtrace
●

gdb ./app

●

gdb ./app corefile

●

gdb –args ./app -foo -bar

2013-10-26

sune.vuorela.dk

9
Corefiler
●

Ulimit -c unlimited

●

Lander i PWD med mindre ...

●

mkdir /cores

●

chmod 777 /cores

●

echo /cores/core.%e.%p >
/proc/sys/kernel/core_pattern

2013-10-26

sune.vuorela.dk

10
gdb
●

Program received signal SIGSEGV,
Segmentation fault.

●

....

●

109

●

(gdb) backtrace

●

(gdb) bt

Q_ASSERT(d);

●

2013-10-26

sune.vuorela.dk

11
Backtrace
●

#0 0x0000000000406b66 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::operator-> (this=0x8) at /usr/include/qt5/QtCore/qscopedpointer.h:109

●

#1 0x0000000000406b50 in QObject::parent (this=0x0) at /usr/include/qt5/QtCore/qobject.h:386

●

#2 0x0000000000406b28 in DereferenceNullPointer::execute (this=0x6adeb0) at /home/sune/projects/sigsegv/kode/dereferencenullpointer.cpp:38

●

#3 0x00000000004080b8 in QtPrivate::FunctionPointer<void (TestCase::*)()>::call<void, void> (f=&virtual table offset 96, o=0x6adeb0, arg=0x7fffffffd390) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:142

●

#4 0x0000000000408005 in QtPrivate::QSlotObject<void (TestCase::*)(), void, void>::impl (which=1, this_=0x667960, r=0x6adeb0, a=0x7fffffffd390, ret=0x0) at /usr/include/qt5/QtCore/qobject_impl.h:147

●

#5 0x00007ffff6baedd3 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

●

#6 0x00007ffff7a60da2 in QAbstractButton::clicked(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#7 0x00007ffff77fa756 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#8 0x00007ffff77fb26e in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#9 0x00007ffff77fb3e4 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#10 0x00007ffff7740b99 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#11 0x00007ffff7706f1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#12 0x00007ffff770c879 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#13 0x00007ffff6b8974d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

●

#14 0x00007ffff770aba1 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#15 0x00007ffff775c8cf in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#16 0x00007ffff775e5e3 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#17 0x00007ffff7706f1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#18 0x00007ffff770c006 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5

●

#19 0x00007ffff6b8974d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

●

#20 0x00007ffff70887a7 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5

●

#21 0x00007ffff708a2a5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5

●

#22 0x00007ffff70749e8 in QWindowSystemInterface::sendWindowSystemEventsImplementation(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5

●

#23 0x00007ffff105a4a0 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so

●

#24 0x00007ffff5662f25 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0

●

#25 0x00007ffff5663268 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0

●

#26 0x00007ffff5663324 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0

●

#27 0x00007ffff6bd05fc in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

●

#28 0x00007ffff6b8849b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

●

#29 0x00007ffff6b8ea21 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

●

#30 0x0000000000406cee in main (argc=1, argv=0x7fffffffe188) at /home/sune/projects/sigsegv/kode/main.cpp:15

●

2013-10-26

sune.vuorela.dk

12
Backtrace
●

●

●

●

●

(gdb) bt
#0 0x0000000000406b66 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData>
>::operator-> (this=0x8) at /usr/include/qt5/QtCore/qscopedpointer.h:109
#1 0x0000000000406b50 in QObject::parent (this=0x0) at /usr/include/qt5/QtCore/qobject.h:386
#2 0x0000000000406b28 in DereferenceNullPointer::execute (this=0x6adeb0) at
/home/sune/projects/sigsegv/kode/dereferencenullpointer.cpp:38
#3 0x00000000004080b8 in QtPrivate::FunctionPointer<void (TestCase::*)()>::call<void, void> (f=&virtual
table offset 96, o=0x6adeb0, arg=0x7fffffffd390) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:142

●

2013-10-26

sune.vuorela.dk

13
Backtrace
●

#2 0x0000000000406b28 in
DereferenceNullPointer::execute
(this=0x6adeb0) at
/home/sune/projects/sigsegv/kode/dereference
nullpointer.cpp:38

2013-10-26

sune.vuorela.dk

14
Kode
●

36

while(true) {

●

37

if(!tmp); {

●

38

tmp = tmp->parent();

●

39

continue;

●

40

}

●

41

break;

●

42

2013-10-26

}
sune.vuorela.dk

15
Status
Set gdb
Læst og forstået backtrace
Parret med kode

2013-10-26

sune.vuorela.dk

16
Mere crash
●

DereferenceDeletedPointer::execute at
/home/sune/projects/sigsegv/kode/dereferenced
eletedpointer.cpp:44

●

2013-10-26

sune.vuorela.dk

17
Kode
●

43

●

44

●

45

2013-10-26

if(m_obj) {
m_obj->length();
}

sune.vuorela.dk

18
Valgrind
●
●

●

Use of uninitialised value of size 8
at 0x406A67: QString::length() const
(qstring.h:735)
by 0x406A54:
DereferenceDeletedPointer::execute()
(dereferencedeletedpointer.cpp:44)

●

2013-10-26

sune.vuorela.dk

19
Mere valgrind
●

Invalid read of size 4

●

at 0x406A67: QString::length() const (qstring.h:735)

●

by 0x406A54: DereferenceDeletedPointer::execute() (dereferencedeletedpointer.cpp:44)

●

●

Address 0x10c7b044 is 4 bytes inside a block of size 34 free'd

●

at 0x4C2AADC: free (vg_replace_malloc.c:446)

●

by 0x406909: QTypedArrayData<unsigned short>::deallocate(QArrayData*) (qarraydata.h:230)

●

by 0x4068B2: QString::~QString() (in /home/sune/projects/sigsegv/kode/build/kode)

●

by 0x406A12: DereferenceDeletedPointer::putDataIn() (dereferencedeletedpointer.cpp:37)

●

by 0x406A37: DereferenceDeletedPointer::execute() (dereferencedeletedpointer.cpp:42)

●

2013-10-26

sune.vuorela.dk

20
Mere kode
●

35 void DereferenceDeletedPointer::putDataIn() {

●

36

QString tmp("foo");

●

37

m_obj = &tmp;

●

38 }

●

41 void DereferenceDeletedPointer::execute() {

●

42

putDataIn();

●

43

if(m_obj) {

●

44

●

45

●

46 }

2013-10-26

m_obj->length();
}

sune.vuorela.dk

21
Simple crash 3
●

●

●

#0 0x0000000000000000 in ?? ()
#1 0x0000000000406805 in DeletePointer::execute
(this=0x665160) at
/home/sune/projects/sigsegv/kode/deletepointer.cpp:3
6
#2 0x00000000004080c4 in
QtPrivate::FunctionPointer<void (TestCase::*)
()>::call<void, void> (f=&virtual table offset 96,
o=0x665160, arg=0x7fffffffd390) at
/usr/include/qt5/QtCore/qobjectdefs_impl.h:142

2013-10-26

sune.vuorela.dk

22
Kode 3
●

34 void DeletePointer::execute() {

●

35

●

36

●

37

●

38 }

2013-10-26

if ( m_pointer ) {
delete m_pointer;
}

sune.vuorela.dk

23
Mere valgrind
●
●

●

●

●

●

==26581== Invalid read of size 8
==26581== at 0x4067EE: DeletePointer::execute()
(deletepointer.cpp:36)
==26581== Address 0x10e240a0 is 0 bytes inside a
block of size 16 free'd
==26581== at 0x4C2A60C: operator delete(void*)
(vg_replace_malloc.c:480)
==26581== by 0x406804: DeletePointer::execute()
(deletepointer.cpp:36)

2013-10-26

sune.vuorela.dk

24
Status
Set gdb
Læst og forstået backtrace
Parret med kode
Set valgrind

2013-10-26

sune.vuorela.dk

25
List
●

BrokenList::execute (this=0x6ced20) at
/home/sune/projects/sigsegv/kode/brokenlist.cp
p:57

2013-10-26

sune.vuorela.dk

26
Kode
●

54

MyList* first = generateList(10);

●

55

MyList* current = first;

●

56

while(current->next) {

●

57

●

58

2013-10-26

current = current->next;
}

sune.vuorela.dk

27
Breakpoints
●

(gdb) break file.c:27

●

(gdb) break myfunction

●

(gdb) break MyClass::myFunction(int)

●
●

(gdb) print variablenavn

●
●

(gdb) continue

2013-10-26

sune.vuorela.dk

28
Debugger
(gdb) b brokenlist.cpp:57
Breakpoint 1, BrokenList::execute (this=0x6d18d0) at
/home/sune/projects/sigsegv/kode/brokenlist.cpp:57
57
current = current->next;
(gdb) p current
$1 = (MyList *) 0x6f8ea0
(gdb) p current->next
$2 = (MyList *) 0x8000b0
(gdb) c
Continuing.
Breakpoint 1, BrokenList::execute (this=0x6d18d0) at
/home/sune/projects/sigsegv/kode/brokenlist.cpp:57
57
current = current->next;

2013-10-26

sune.vuorela.dk

29
Status
Set gdb
Læst og forstået backtrace
Parret med kode
Set valgrind
Breakpoints og print i gdb

2013-10-26

sune.vuorela.dk

30
Gdb ignore
●
●

(gdb) b brokenlist.cpp:57
Breakpoint 1 at 0x406fa8: file
/home/sune/projects/sigsegv/kode/brokenlist.cp
p, line 57.

●

(gdb) ignore 1 8

●

Will ignore next 8 crossings of breakpoint 1.

2013-10-26

sune.vuorela.dk

31
Locals
●

(gdb) info locals

●

first = 0x7ff2c0

●

current = 0xfeeefeee

●
●

(gdb) up 4

●

(gdb) down 4

2013-10-26

sune.vuorela.dk

32
GDB conditions
●

●

gdb) b brokenlist.cpp:57
Breakpoint 1 at 0x406fa8: file
/home/sune/projects/sigsegv/kode/brokenlist.cpp, line 57.

●

(gdb) condition 1 current->next == (MyList *)0xfeeefeee

●

(gdb) c

●

Continuing.

●

Breakpoint 1, BrokenList::execute (this=0x6ced20) at
/home/sune/projects/sigsegv/kode/brokenlist.cpp:57

●

57

●

(gdb) p current->next

●

$2 = (MyList *) 0xfeeefeee

2013-10-26

current = current->next;

sune.vuorela.dk

33
Status
Set gdb
Læst og forstået backtrace
Parret med kode
Set valgrind
Breakpoints og print i gdb
Conditional breakpoints, locals
2013-10-26

sune.vuorela.dk

34
Gdb stepping
●

(gdb) next -- kører til næste linje i filen

●
●

(gdb) step – træder ind i funktionenn

●
●

(gdb) finish – kører funktionen færdig

2013-10-26

sune.vuorela.dk

35
Minisegfault
●

$ echo -n "main;" > fil.c

●

$ gcc fil.c

●

fil.c:1:1: warning: data definition has no type
or storage class [enabled by default]

●

$ ./a.out

●

Segmentation fault

2013-10-26

sune.vuorela.dk

36
Mere
●

Valgrind –db-attach=yes ./kode

●
●

Gdb: tbreak – temporary breakpoint

●
●

Gdb: record - reverse-next

2013-10-26

sune.vuorela.dk

37
Tak
Spørgsmål?
sune@{vuorela.dk,debian.org,kde.org}

Más contenido relacionado

Destacado

Insight live om IT-sikkerhed - Thomas Lund-Sørensen
Insight live om IT-sikkerhed - Thomas Lund-SørensenInsight live om IT-sikkerhed - Thomas Lund-Sørensen
Insight live om IT-sikkerhed - Thomas Lund-SørensenMediehuset Ingeniøren Live
 
Digital project management - Magnus Holmlid, Visuell Planering
Digital project management - Magnus Holmlid, Visuell PlaneringDigital project management - Magnus Holmlid, Visuell Planering
Digital project management - Magnus Holmlid, Visuell PlaneringMediehuset Ingeniøren Live
 
Dansk projektledelse: IPMA certificering af projektledere
Dansk projektledelse:  IPMA certificering af projektledereDansk projektledelse:  IPMA certificering af projektledere
Dansk projektledelse: IPMA certificering af projektledereMediehuset Ingeniøren Live
 
Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...
Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...
Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...Mediehuset Ingeniøren Live
 
Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014
Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014
Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014Mediehuset Ingeniøren Live
 
Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...
Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...
Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...Mediehuset Ingeniøren Live
 

Destacado (13)

Thomas Hansen - information management
Thomas Hansen - information management Thomas Hansen - information management
Thomas Hansen - information management
 
Insight live om IT-sikkerhed - Thomas Lund-Sørensen
Insight live om IT-sikkerhed - Thomas Lund-SørensenInsight live om IT-sikkerhed - Thomas Lund-Sørensen
Insight live om IT-sikkerhed - Thomas Lund-Sørensen
 
Debugging 2013- Michael Rasmussen
Debugging 2013- Michael RasmussenDebugging 2013- Michael Rasmussen
Debugging 2013- Michael Rasmussen
 
Datacenter 2014: Trend Micro - Bill MCGee
Datacenter 2014: Trend Micro - Bill MCGeeDatacenter 2014: Trend Micro - Bill MCGee
Datacenter 2014: Trend Micro - Bill MCGee
 
Debugging 2013- Jesper Brouer
Debugging 2013- Jesper BrouerDebugging 2013- Jesper Brouer
Debugging 2013- Jesper Brouer
 
Digital project management - Magnus Holmlid, Visuell Planering
Digital project management - Magnus Holmlid, Visuell PlaneringDigital project management - Magnus Holmlid, Visuell Planering
Digital project management - Magnus Holmlid, Visuell Planering
 
Dit CV din fremtid
Dit CV din fremtidDit CV din fremtid
Dit CV din fremtid
 
Dansk projektledelse: IPMA certificering af projektledere
Dansk projektledelse:  IPMA certificering af projektledereDansk projektledelse:  IPMA certificering af projektledere
Dansk projektledelse: IPMA certificering af projektledere
 
Pitch slides datacenter 2014 færdige
Pitch slides datacenter 2014 færdigePitch slides datacenter 2014 færdige
Pitch slides datacenter 2014 færdige
 
Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...
Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...
Syddansk Universitet:Master i projektledelse er en 2-årig forskningsbaseret e...
 
Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014
Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014
Mikkel Munk Quist Andersen: Gennemgang af Ingeniørens profilanalyse 2014
 
Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...
Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...
Ulla Plüger Michelsen - Rekuttering og branding forankret i virksomhedens kul...
 
Agenda rum 204 2014
Agenda rum 204 2014Agenda rum 204 2014
Agenda rum 204 2014
 

Similar a Debugging 2013- Sune Vuorela

Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...
Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...
Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...Igalia
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: BasicKAI CHU CHUNG
 
Gdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) finalGdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) finalValeriy Kravchuk
 
How to integrate front end tool via gruntjs
How to integrate front end tool via gruntjsHow to integrate front end tool via gruntjs
How to integrate front end tool via gruntjsBo-Yi Wu
 
GKE_ How I get started_.pdf
GKE_ How I get started_.pdfGKE_ How I get started_.pdf
GKE_ How I get started_.pdfLuillyfe Blanco
 
Glusterfs geo-replication
Glusterfs geo-replicationGlusterfs geo-replication
Glusterfs geo-replicationbipin kunal
 
Trace kernel code tips
Trace kernel code tipsTrace kernel code tips
Trace kernel code tipsViller Hsiao
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源KAI CHU CHUNG
 
LCU14 201- Binary Analysis Tools
LCU14 201- Binary Analysis ToolsLCU14 201- Binary Analysis Tools
LCU14 201- Binary Analysis ToolsLinaro
 
Geo-Replication and Disaster Recovery : Glusterfs
Geo-Replication and Disaster Recovery : GlusterfsGeo-Replication and Disaster Recovery : Glusterfs
Geo-Replication and Disaster Recovery : Glusterfsbipin kunal
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceBo-Yi Wu
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBbmbouter
 
[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free SoftwareSamuel Iglesias Gonsálvez
 
How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)Igalia
 
Sprint 131
Sprint 131Sprint 131
Sprint 131ManageIQ
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐KAI CHU CHUNG
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringJano Suchal
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudAndrea Righi
 

Similar a Debugging 2013- Sune Vuorela (20)

Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...
Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...
Building Chromium on an Embedded Platform using Ozone-Wayland Layer (GENIVI 1...
 
Google App Engine: Basic
Google App Engine: BasicGoogle App Engine: Basic
Google App Engine: Basic
 
Gdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) finalGdb basics for my sql db as (openfest 2017) final
Gdb basics for my sql db as (openfest 2017) final
 
How to integrate front end tool via gruntjs
How to integrate front end tool via gruntjsHow to integrate front end tool via gruntjs
How to integrate front end tool via gruntjs
 
GKE_ How I get started_.pdf
GKE_ How I get started_.pdfGKE_ How I get started_.pdf
GKE_ How I get started_.pdf
 
Glusterfs geo-replication
Glusterfs geo-replicationGlusterfs geo-replication
Glusterfs geo-replication
 
Trace kernel code tips
Trace kernel code tipsTrace kernel code tips
Trace kernel code tips
 
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
COSCUP 2020 Google 技術 x 公共參與 x 開源 口罩地圖技術開源
 
Tp cms-g1-v4
Tp cms-g1-v4Tp cms-g1-v4
Tp cms-g1-v4
 
LCU14 201- Binary Analysis Tools
LCU14 201- Binary Analysis ToolsLCU14 201- Binary Analysis Tools
LCU14 201- Binary Analysis Tools
 
Geo-Replication and Disaster Recovery : Glusterfs
Geo-Replication and Disaster Recovery : GlusterfsGeo-Replication and Disaster Recovery : Glusterfs
Geo-Replication and Disaster Recovery : Glusterfs
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript Conference
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDB
 
CADM4.pptx
CADM4.pptxCADM4.pptx
CADM4.pptx
 
[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software[FOSDEM 2015] How to test OpenGL drivers using Free Software
[FOSDEM 2015] How to test OpenGL drivers using Free Software
 
How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)How to test OpenGL drivers using Free Software (FOSDEM 2015)
How to test OpenGL drivers using Free Software (FOSDEM 2015)
 
Sprint 131
Sprint 131Sprint 131
Sprint 131
 
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐Coscup x ruby conf tw 2021  google cloud buildpacks 剖析與實踐
Coscup x ruby conf tw 2021 google cloud buildpacks 剖析與實踐
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoring
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 

Último

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Último (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

Debugging 2013- Sune Vuorela

  • 1. SIGSEGV Sune Vuorela Debugging | København | Oktober 2013
  • 9. Få fat i backtrace ● gdb ./app ● gdb ./app corefile ● gdb –args ./app -foo -bar 2013-10-26 sune.vuorela.dk 9
  • 10. Corefiler ● Ulimit -c unlimited ● Lander i PWD med mindre ... ● mkdir /cores ● chmod 777 /cores ● echo /cores/core.%e.%p > /proc/sys/kernel/core_pattern 2013-10-26 sune.vuorela.dk 10
  • 11. gdb ● Program received signal SIGSEGV, Segmentation fault. ● .... ● 109 ● (gdb) backtrace ● (gdb) bt Q_ASSERT(d); ● 2013-10-26 sune.vuorela.dk 11
  • 12. Backtrace ● #0 0x0000000000406b66 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::operator-> (this=0x8) at /usr/include/qt5/QtCore/qscopedpointer.h:109 ● #1 0x0000000000406b50 in QObject::parent (this=0x0) at /usr/include/qt5/QtCore/qobject.h:386 ● #2 0x0000000000406b28 in DereferenceNullPointer::execute (this=0x6adeb0) at /home/sune/projects/sigsegv/kode/dereferencenullpointer.cpp:38 ● #3 0x00000000004080b8 in QtPrivate::FunctionPointer<void (TestCase::*)()>::call<void, void> (f=&virtual table offset 96, o=0x6adeb0, arg=0x7fffffffd390) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:142 ● #4 0x0000000000408005 in QtPrivate::QSlotObject<void (TestCase::*)(), void, void>::impl (which=1, this_=0x667960, r=0x6adeb0, a=0x7fffffffd390, ret=0x0) at /usr/include/qt5/QtCore/qobject_impl.h:147 ● #5 0x00007ffff6baedd3 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ● #6 0x00007ffff7a60da2 in QAbstractButton::clicked(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #7 0x00007ffff77fa756 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #8 0x00007ffff77fb26e in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #9 0x00007ffff77fb3e4 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #10 0x00007ffff7740b99 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #11 0x00007ffff7706f1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #12 0x00007ffff770c879 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #13 0x00007ffff6b8974d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ● #14 0x00007ffff770aba1 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #15 0x00007ffff775c8cf in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #16 0x00007ffff775e5e3 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #17 0x00007ffff7706f1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #18 0x00007ffff770c006 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 ● #19 0x00007ffff6b8974d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ● #20 0x00007ffff70887a7 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 ● #21 0x00007ffff708a2a5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 ● #22 0x00007ffff70749e8 in QWindowSystemInterface::sendWindowSystemEventsImplementation(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 ● #23 0x00007ffff105a4a0 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so ● #24 0x00007ffff5662f25 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 ● #25 0x00007ffff5663268 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 ● #26 0x00007ffff5663324 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 ● #27 0x00007ffff6bd05fc in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ● #28 0x00007ffff6b8849b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ● #29 0x00007ffff6b8ea21 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 ● #30 0x0000000000406cee in main (argc=1, argv=0x7fffffffe188) at /home/sune/projects/sigsegv/kode/main.cpp:15 ● 2013-10-26 sune.vuorela.dk 12
  • 13. Backtrace ● ● ● ● ● (gdb) bt #0 0x0000000000406b66 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::operator-> (this=0x8) at /usr/include/qt5/QtCore/qscopedpointer.h:109 #1 0x0000000000406b50 in QObject::parent (this=0x0) at /usr/include/qt5/QtCore/qobject.h:386 #2 0x0000000000406b28 in DereferenceNullPointer::execute (this=0x6adeb0) at /home/sune/projects/sigsegv/kode/dereferencenullpointer.cpp:38 #3 0x00000000004080b8 in QtPrivate::FunctionPointer<void (TestCase::*)()>::call<void, void> (f=&virtual table offset 96, o=0x6adeb0, arg=0x7fffffffd390) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:142 ● 2013-10-26 sune.vuorela.dk 13
  • 14. Backtrace ● #2 0x0000000000406b28 in DereferenceNullPointer::execute (this=0x6adeb0) at /home/sune/projects/sigsegv/kode/dereference nullpointer.cpp:38 2013-10-26 sune.vuorela.dk 14
  • 15. Kode ● 36 while(true) { ● 37 if(!tmp); { ● 38 tmp = tmp->parent(); ● 39 continue; ● 40 } ● 41 break; ● 42 2013-10-26 } sune.vuorela.dk 15
  • 16. Status Set gdb Læst og forstået backtrace Parret med kode 2013-10-26 sune.vuorela.dk 16
  • 19. Valgrind ● ● ● Use of uninitialised value of size 8 at 0x406A67: QString::length() const (qstring.h:735) by 0x406A54: DereferenceDeletedPointer::execute() (dereferencedeletedpointer.cpp:44) ● 2013-10-26 sune.vuorela.dk 19
  • 20. Mere valgrind ● Invalid read of size 4 ● at 0x406A67: QString::length() const (qstring.h:735) ● by 0x406A54: DereferenceDeletedPointer::execute() (dereferencedeletedpointer.cpp:44) ● ● Address 0x10c7b044 is 4 bytes inside a block of size 34 free'd ● at 0x4C2AADC: free (vg_replace_malloc.c:446) ● by 0x406909: QTypedArrayData<unsigned short>::deallocate(QArrayData*) (qarraydata.h:230) ● by 0x4068B2: QString::~QString() (in /home/sune/projects/sigsegv/kode/build/kode) ● by 0x406A12: DereferenceDeletedPointer::putDataIn() (dereferencedeletedpointer.cpp:37) ● by 0x406A37: DereferenceDeletedPointer::execute() (dereferencedeletedpointer.cpp:42) ● 2013-10-26 sune.vuorela.dk 20
  • 21. Mere kode ● 35 void DereferenceDeletedPointer::putDataIn() { ● 36 QString tmp("foo"); ● 37 m_obj = &tmp; ● 38 } ● 41 void DereferenceDeletedPointer::execute() { ● 42 putDataIn(); ● 43 if(m_obj) { ● 44 ● 45 ● 46 } 2013-10-26 m_obj->length(); } sune.vuorela.dk 21
  • 22. Simple crash 3 ● ● ● #0 0x0000000000000000 in ?? () #1 0x0000000000406805 in DeletePointer::execute (this=0x665160) at /home/sune/projects/sigsegv/kode/deletepointer.cpp:3 6 #2 0x00000000004080c4 in QtPrivate::FunctionPointer<void (TestCase::*) ()>::call<void, void> (f=&virtual table offset 96, o=0x665160, arg=0x7fffffffd390) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:142 2013-10-26 sune.vuorela.dk 22
  • 23. Kode 3 ● 34 void DeletePointer::execute() { ● 35 ● 36 ● 37 ● 38 } 2013-10-26 if ( m_pointer ) { delete m_pointer; } sune.vuorela.dk 23
  • 24. Mere valgrind ● ● ● ● ● ● ==26581== Invalid read of size 8 ==26581== at 0x4067EE: DeletePointer::execute() (deletepointer.cpp:36) ==26581== Address 0x10e240a0 is 0 bytes inside a block of size 16 free'd ==26581== at 0x4C2A60C: operator delete(void*) (vg_replace_malloc.c:480) ==26581== by 0x406804: DeletePointer::execute() (deletepointer.cpp:36) 2013-10-26 sune.vuorela.dk 24
  • 25. Status Set gdb Læst og forstået backtrace Parret med kode Set valgrind 2013-10-26 sune.vuorela.dk 25
  • 27. Kode ● 54 MyList* first = generateList(10); ● 55 MyList* current = first; ● 56 while(current->next) { ● 57 ● 58 2013-10-26 current = current->next; } sune.vuorela.dk 27
  • 28. Breakpoints ● (gdb) break file.c:27 ● (gdb) break myfunction ● (gdb) break MyClass::myFunction(int) ● ● (gdb) print variablenavn ● ● (gdb) continue 2013-10-26 sune.vuorela.dk 28
  • 29. Debugger (gdb) b brokenlist.cpp:57 Breakpoint 1, BrokenList::execute (this=0x6d18d0) at /home/sune/projects/sigsegv/kode/brokenlist.cpp:57 57 current = current->next; (gdb) p current $1 = (MyList *) 0x6f8ea0 (gdb) p current->next $2 = (MyList *) 0x8000b0 (gdb) c Continuing. Breakpoint 1, BrokenList::execute (this=0x6d18d0) at /home/sune/projects/sigsegv/kode/brokenlist.cpp:57 57 current = current->next; 2013-10-26 sune.vuorela.dk 29
  • 30. Status Set gdb Læst og forstået backtrace Parret med kode Set valgrind Breakpoints og print i gdb 2013-10-26 sune.vuorela.dk 30
  • 31. Gdb ignore ● ● (gdb) b brokenlist.cpp:57 Breakpoint 1 at 0x406fa8: file /home/sune/projects/sigsegv/kode/brokenlist.cp p, line 57. ● (gdb) ignore 1 8 ● Will ignore next 8 crossings of breakpoint 1. 2013-10-26 sune.vuorela.dk 31
  • 32. Locals ● (gdb) info locals ● first = 0x7ff2c0 ● current = 0xfeeefeee ● ● (gdb) up 4 ● (gdb) down 4 2013-10-26 sune.vuorela.dk 32
  • 33. GDB conditions ● ● gdb) b brokenlist.cpp:57 Breakpoint 1 at 0x406fa8: file /home/sune/projects/sigsegv/kode/brokenlist.cpp, line 57. ● (gdb) condition 1 current->next == (MyList *)0xfeeefeee ● (gdb) c ● Continuing. ● Breakpoint 1, BrokenList::execute (this=0x6ced20) at /home/sune/projects/sigsegv/kode/brokenlist.cpp:57 ● 57 ● (gdb) p current->next ● $2 = (MyList *) 0xfeeefeee 2013-10-26 current = current->next; sune.vuorela.dk 33
  • 34. Status Set gdb Læst og forstået backtrace Parret med kode Set valgrind Breakpoints og print i gdb Conditional breakpoints, locals 2013-10-26 sune.vuorela.dk 34
  • 35. Gdb stepping ● (gdb) next -- kører til næste linje i filen ● ● (gdb) step – træder ind i funktionenn ● ● (gdb) finish – kører funktionen færdig 2013-10-26 sune.vuorela.dk 35
  • 36. Minisegfault ● $ echo -n "main;" > fil.c ● $ gcc fil.c ● fil.c:1:1: warning: data definition has no type or storage class [enabled by default] ● $ ./a.out ● Segmentation fault 2013-10-26 sune.vuorela.dk 36
  • 37. Mere ● Valgrind –db-attach=yes ./kode ● ● Gdb: tbreak – temporary breakpoint ● ● Gdb: record - reverse-next 2013-10-26 sune.vuorela.dk 37