SlideShare une entreprise Scribd logo
1  sur  38
Télécharger pour lire hors ligne
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}

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

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