SlideShare a Scribd company logo
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}

More Related Content

Viewers also liked

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
Mediehuset Ingeniøren Live
 

Viewers also liked (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 to Debugging 2013- Sune Vuorela

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
Bo-Yi Wu
 
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
Jano Suchal
 

Similar to 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
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

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