SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
inequation.org
inequation.org

Gamedev-grade debugging
Leszek Godlewski
Freelance Programmer
lg@inequation.org

SpreadIT 2013 · October 19th, 2013
SpreadIT 2013 · October 19th, 2013
Code snippets
Code snippets

All code used in the talk available online:
github.com/inequation/ggd

2
2

inequation.org
inequation.org
Agenda
Agenda

●

Who is this guy?

●

Why the talk?

●

A taste of gamedev debugging

●

Right tool for the job

●

Noise filtering

●

Memory corruption

●

Questions

3
3

inequation.org
inequation.org
Who is this guy?
Who is this guy?

Freelance Programmer
●
●

●

(Sep 2013 – onwards)
inequation.org
Painkiller Hell & Damnation
Linux port finalization (2013)
Unannounced project

Generalist Programmer,
The Farm 51
●
●

●

●

4
4

(Mar 2010 – Aug 2013)
thefarm51.com
Painkiller Hell & Damnation
(2012-2013; Win/Linux/X360/PS3)
Deadfall Adventures
(2011-2013; Win/X360)
A few unannounced projects
inequation.org
inequation.org
Agenda
Agenda

●

Who is this guy?

●

Why the talk?

●

A taste of gamedev debugging

●

Right tool for the job

●

Noise filtering

●

Memory corruption

●

Questions

5
5

inequation.org
inequation.org
Why the talk?
Why the talk?

Because THIS has happened to me:

http://imgur.com/yBa1OGm

6
6

inequation.org
inequation.org
Why the talk?
Why the talk?

Intern: I've read* at all the code and
still don't see the bug.
Me:

So just debug it!

*read, as in „stare without actually running it”

7
7

inequation.org
inequation.org
Why the talk?
Why the talk?

Intern:

© DreamWorks

8
8

http://imgur.com/yBa1OGm

inequation.org
inequation.org
Why the talk?
Why the talk?

The three uses of debugging
●

Bug hunting (doh)

●
●

9
9

inequation.org
inequation.org
Why the talk?
Why the talk?

The three uses of debugging
Bug hunting (doh)
● Reverse engineering
●

●

10
10

inequation.org
inequation.org
Why the talk?
Why the talk?

The three uses of debugging
Bug hunting (doh)
● Reverse engineering
● Testing a new feature
●

11
11

inequation.org
inequation.org
Agenda
Agenda

●

Who is this guy?

●

Why the talk?

●

A taste of gamedev debugging

●

Right tool for the job

●

Noise filtering

●

Memory corruption

●

Questions

12
12

inequation.org
inequation.org
A taste of gamedev debugging
A taste of gamedev debugging

Code: 01-taste

13
13

inequation.org
inequation.org
A taste of gamedev debugging
A taste of gamedev debugging

Can you spot the culprit?
// class declaration
class Crasher extends ActorComponent;
var int DummyArray[1024];
// in ammo consumption code
Crash = new class'Crasher';
Comp = new class'ActorComponent' (Crash);

14
14

inequation.org
inequation.org
Agenda
Agenda

●

Who is this guy?

●

Why the talk?

●

A taste of gamedev debugging

●

Right tool for the job

●

Noise filtering

●

Memory corruption

●

Questions

15
15

inequation.org
inequation.org
Right tool for the job
Right tool for the job

„Fix a bug for an intern, they will get stuck on
the next one.
Teach them debugging, they will fix most bugs
they encounter on their own.”

– Paulo Coelho

16
16

inequation.org
inequation.org
Right tool for the job
Right tool for the job

Debugging tools are essential to this
profession!
When joining a new team or starting development for a
new platform, demand debugging tools
● Ask senior teammates
● If they don't know, there must be documentation
● Be proactive!
● Don't give up until the debugger is fully working
● No tools? Roll your own!
● You are a coder after all, right?
●

17
17

inequation.org
inequation.org
Right tool for the job
Right tool for the job

Not all bugs are in the code
Animation graphs
● Flow graphs/visual scripts
● Post-process effects
●

Still need a way to debug them

18
18

inequation.org
inequation.org
Right tool for the job
Right tool for the job

Code: 02-tools

19
19

inequation.org
inequation.org
Agenda
Agenda

●

Who is this guy?

●

Why the talk?

●

A taste of gamedev debugging

●

Right tool for the job

●

Noise filtering

●

Memory corruption

●

Questions

20
20

inequation.org
inequation.org
Noise filtering
Noise filtering

There are parts of code executed thousands
of times each frame
Object transformation
● Collision detection
●

Also rarer, but still impractical to track
Setting materials on objects
● Attaching and detaching of components
●

21
21

inequation.org
inequation.org
Noise filtering
Noise filtering
Code: 03-material
04-ragdoll
05-assert

22
22

inequation.org
inequation.org
Agenda
Agenda

●

Who is this guy?

●

Why the talk?

●

A taste of gamedev debugging

●

Right tool for the job

●

Noise filtering

●

Memory corruption

●

Questions

23
23

inequation.org
inequation.org
Memory corruption
Memory corruption

Look closely:
// class declaration
class Crasher extends ActorComponent;
var int DummyArray[1024];
// in ammo consumption code
Crash = new class'Crasher';
Comp = new class'ActorComponent' (Crash);

24
24

inequation.org
inequation.org
Memory corruption
Memory corruption

Look closely:
// class declaration
class Crasher extends ActorComponent;
var int DummyArray[1024];
// in ammo consumption code
Crash = new class'Crasher';
Comp = new class'ActorComponent' (Crash);

25
25

inequation.org
inequation.org
Memory corruption
Memory corruption

●

UnrealScript object construction syntax
new <class> [(<template object>)];

●

But:
sizeof(Crasher) > sizeof(ActorComponent)

●

Verdict:

26
26

inequation.org
inequation.org
Memory corruption
Memory corruption

●

UnrealScript object construction syntax
new <class> [(<template object>)];

●

But:
sizeof(Crasher) > sizeof(ActorComponent)

●

Verdict:

27
27

BUFFER OVERFLOW!

inequation.org
inequation.org
Memory corruption
Memory corruption

But this can happen anywhere! How to find it?
Use a memory fence
● Many related techniques
● Allocate additional space in front and behind actual
allocations
● Then protect them from writing...
● Or write a byte pattern and periodically assert its
consistency
● Also it's useful to log stack traces
● Memory and CPU overhead!
● Use a debug memory allocator (dmalloc)
● Use a memory debugger (Valgrind)
● Use a memory analysis tool (HeapInspector)
●

28
28

inequation.org
inequation.org
Memory corruption
Memory corruption

Memory fences

malloc

Regular allocation

29
29

malloc

Fenced allocation

inequation.org
inequation.org
Takeaway
Takeaway

You can't be an effective programmer without
debugging tools
● If there are no tools, make some
● Noise filtering techniques save your time
● Time is not only money – nerves are just as important!
● Know your machine (physical or virtual) down to the
metal
● Instruction opcodes, registers etc. come in handy
● Tons of resources available
● Random crashes and/or content glitches may indicate
memory corruption
● Memory corruption can be defeated!
●

30
30

inequation.org
inequation.org
inequation.org
inequation.org

Questions?
lg@inequation.org

SpreadIT 2013 · October 19th, 2013
SpreadIT 2013 · October 19th, 2013
inequation.org
inequation.org

Thank you!
inequation.org
lg@inequation.org
@TheIneQuation

SpreadIT 2013 · October 19th, 2013
SpreadIT 2013 · October 19th, 2013

Mais conteúdo relacionado

Mais procurados

Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)Aaron Schlesinger
 
Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Peter Kofler
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHPRogério Vicente
 
Angular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular appsAngular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular appsMartin Hochel
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Peter Kofler
 

Mais procurados (8)

Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)
 
Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
Angular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular appsAngular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular apps
 
Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)Coding Dojo: Naming with Dices (2021)
Coding Dojo: Naming with Dices (2021)
 
MSL2008. Debugging
MSL2008. DebuggingMSL2008. Debugging
MSL2008. Debugging
 
Server side swift
Server side swiftServer side swift
Server side swift
 

Destaque

El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después espejodeoesed
 
Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Fikriyyah George
 
Crisis Subprime en España
Crisis Subprime en EspañaCrisis Subprime en España
Crisis Subprime en Españaespejodeoesed
 
One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesLeszek Godlewski
 
CriminalEFS-PowerPoint
CriminalEFS-PowerPointCriminalEFS-PowerPoint
CriminalEFS-PowerPointJenn Amabile
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - ErrataLeszek Godlewski
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLeszek Godlewski
 
каталог керасис
каталог керасискаталог керасис
каталог керасисNastasik
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Leszek Godlewski
 
Хипстеры в энтерпрайзе
Хипстеры в энтерпрайзеХипстеры в энтерпрайзе
Хипстеры в энтерпрайзеAleksandr Tarasov
 
Advanced Linux Game Programming
Advanced Linux Game ProgrammingAdvanced Linux Game Programming
Advanced Linux Game ProgrammingLeszek Godlewski
 
Service Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsService Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsAleksandr Tarasov
 

Destaque (19)

El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después El presidencialismo mexicano antes y después
El presidencialismo mexicano antes y después
 
Imágenes inmersivas
Imágenes inmersivasImágenes inmersivas
Imágenes inmersivas
 
Suir img
Suir imgSuir img
Suir img
 
El barrroco
El barrrocoEl barrroco
El barrroco
 
Green Peace y WWF
Green Peace y WWFGreen Peace y WWF
Green Peace y WWF
 
Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses Social Media For Busy Entrepreneurs and Small Businesses
Social Media For Busy Entrepreneurs and Small Businesses
 
Crisis Subprime en España
Crisis Subprime en EspañaCrisis Subprime en España
Crisis Subprime en España
 
One Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launchesOne Year of Porting - Post-mortem of two Linux/SteamOS launches
One Year of Porting - Post-mortem of two Linux/SteamOS launches
 
CriminalEFS-PowerPoint
CriminalEFS-PowerPointCriminalEFS-PowerPoint
CriminalEFS-PowerPoint
 
Linux as a gaming platform - Errata
Linux as a gaming platform - ErrataLinux as a gaming platform - Errata
Linux as a gaming platform - Errata
 
Ecosistemas
EcosistemasEcosistemas
Ecosistemas
 
Linux as a gaming platform, ideology aside
Linux as a gaming platform, ideology asideLinux as a gaming platform, ideology aside
Linux as a gaming platform, ideology aside
 
каталог керасис
каталог керасискаталог керасис
каталог керасис
 
Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0Cross-platform game engine development with SDL 2.0
Cross-platform game engine development with SDL 2.0
 
Хипстеры в энтерпрайзе
Хипстеры в энтерпрайзеХипстеры в энтерпрайзе
Хипстеры в энтерпрайзе
 
OpenGL (ES) debugging
OpenGL (ES) debuggingOpenGL (ES) debugging
OpenGL (ES) debugging
 
Advanced Linux Game Programming
Advanced Linux Game ProgrammingAdvanced Linux Game Programming
Advanced Linux Game Programming
 
Docker In Bank Unrated
Docker In Bank UnratedDocker In Bank Unrated
Docker In Bank Unrated
 
Service Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud InternalsService Discovery. Spring Cloud Internals
Service Discovery. Spring Cloud Internals
 

Semelhante a Gamedev-grade debugging

Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerNaoto Ono
 
My talk on Piter Py 2016
My talk on Piter Py 2016My talk on Piter Py 2016
My talk on Piter Py 2016Alex Chistyakov
 
IntoWebGL - Unite Melbourne 2015
IntoWebGL - Unite Melbourne 2015IntoWebGL - Unite Melbourne 2015
IntoWebGL - Unite Melbourne 2015Ryan Alcock
 
PyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedPyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedAlessandro Molina
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
JSHint: Learning JavaScript the Hard Way
JSHint: Learning JavaScript the Hard WayJSHint: Learning JavaScript the Hard Way
JSHint: Learning JavaScript the Hard WayAdrian-Tudor Panescu
 
Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...
Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...
Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...Demi Ben-Ari
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentKarim Yaghmour
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy CodeAndrea Polci
 
Dear compiler please don't be my nanny v2
Dear compiler  please don't be my nanny v2Dear compiler  please don't be my nanny v2
Dear compiler please don't be my nanny v2Dino Dini
 

Semelhante a Gamedev-grade debugging (20)

Killer Bugs From Outer Space
Killer Bugs From Outer SpaceKiller Bugs From Outer Space
Killer Bugs From Outer Space
 
Introduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debuggerIntroduction of Tools for providing rich user experience in debugger
Introduction of Tools for providing rich user experience in debugger
 
My talk on Piter Py 2016
My talk on Piter Py 2016My talk on Piter Py 2016
My talk on Piter Py 2016
 
IntoWebGL - Unite Melbourne 2015
IntoWebGL - Unite Melbourne 2015IntoWebGL - Unite Melbourne 2015
IntoWebGL - Unite Melbourne 2015
 
PyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development UpdatedPyConUK 2014 - PostMortem Debugging and Web Development Updated
PyConUK 2014 - PostMortem Debugging and Web Development Updated
 
Transitioning to Native
Transitioning to NativeTransitioning to Native
Transitioning to Native
 
Y U NO CRAFTSMAN
Y U NO CRAFTSMANY U NO CRAFTSMAN
Y U NO CRAFTSMAN
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Agileee 2012
Agileee 2012Agileee 2012
Agileee 2012
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
JSHint: Learning JavaScript the Hard Way
JSHint: Learning JavaScript the Hard WayJSHint: Learning JavaScript the Hard Way
JSHint: Learning JavaScript the Hard Way
 
Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...
Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...
Hacker vs company, Cloud Cyber Security Automated with Kubernetes - Demi Ben-...
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Headless Android
Headless AndroidHeadless Android
Headless Android
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Working With Legacy Code
Working With Legacy CodeWorking With Legacy Code
Working With Legacy Code
 
Dear compiler please don't be my nanny v2
Dear compiler  please don't be my nanny v2Dear compiler  please don't be my nanny v2
Dear compiler please don't be my nanny v2
 

Último

Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
RAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIRAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIUdaiappa Ramachandran
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdfJamie (Taka) Wang
 
Things you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceThings you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceMartin Humpolec
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxYounusS2
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 

Último (20)

Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
RAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AIRAG Patterns and Vector Search in Generative AI
RAG Patterns and Vector Search in Generative AI
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
20200723_insight_release_plan_v6.pdf20200723_insight_release_plan_v6.pdf
 
Things you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceThings you didn't know you can use in your Salesforce
Things you didn't know you can use in your Salesforce
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Babel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptxBabel Compiler - Transforming JavaScript for All Browsers.pptx
Babel Compiler - Transforming JavaScript for All Browsers.pptx
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 

Gamedev-grade debugging

  • 1. inequation.org inequation.org Gamedev-grade debugging Leszek Godlewski Freelance Programmer lg@inequation.org SpreadIT 2013 · October 19th, 2013 SpreadIT 2013 · October 19th, 2013
  • 2. Code snippets Code snippets All code used in the talk available online: github.com/inequation/ggd 2 2 inequation.org inequation.org
  • 3. Agenda Agenda ● Who is this guy? ● Why the talk? ● A taste of gamedev debugging ● Right tool for the job ● Noise filtering ● Memory corruption ● Questions 3 3 inequation.org inequation.org
  • 4. Who is this guy? Who is this guy? Freelance Programmer ● ● ● (Sep 2013 – onwards) inequation.org Painkiller Hell & Damnation Linux port finalization (2013) Unannounced project Generalist Programmer, The Farm 51 ● ● ● ● 4 4 (Mar 2010 – Aug 2013) thefarm51.com Painkiller Hell & Damnation (2012-2013; Win/Linux/X360/PS3) Deadfall Adventures (2011-2013; Win/X360) A few unannounced projects inequation.org inequation.org
  • 5. Agenda Agenda ● Who is this guy? ● Why the talk? ● A taste of gamedev debugging ● Right tool for the job ● Noise filtering ● Memory corruption ● Questions 5 5 inequation.org inequation.org
  • 6. Why the talk? Why the talk? Because THIS has happened to me: http://imgur.com/yBa1OGm 6 6 inequation.org inequation.org
  • 7. Why the talk? Why the talk? Intern: I've read* at all the code and still don't see the bug. Me: So just debug it! *read, as in „stare without actually running it” 7 7 inequation.org inequation.org
  • 8. Why the talk? Why the talk? Intern: © DreamWorks 8 8 http://imgur.com/yBa1OGm inequation.org inequation.org
  • 9. Why the talk? Why the talk? The three uses of debugging ● Bug hunting (doh) ● ● 9 9 inequation.org inequation.org
  • 10. Why the talk? Why the talk? The three uses of debugging Bug hunting (doh) ● Reverse engineering ● ● 10 10 inequation.org inequation.org
  • 11. Why the talk? Why the talk? The three uses of debugging Bug hunting (doh) ● Reverse engineering ● Testing a new feature ● 11 11 inequation.org inequation.org
  • 12. Agenda Agenda ● Who is this guy? ● Why the talk? ● A taste of gamedev debugging ● Right tool for the job ● Noise filtering ● Memory corruption ● Questions 12 12 inequation.org inequation.org
  • 13. A taste of gamedev debugging A taste of gamedev debugging Code: 01-taste 13 13 inequation.org inequation.org
  • 14. A taste of gamedev debugging A taste of gamedev debugging Can you spot the culprit? // class declaration class Crasher extends ActorComponent; var int DummyArray[1024]; // in ammo consumption code Crash = new class'Crasher'; Comp = new class'ActorComponent' (Crash); 14 14 inequation.org inequation.org
  • 15. Agenda Agenda ● Who is this guy? ● Why the talk? ● A taste of gamedev debugging ● Right tool for the job ● Noise filtering ● Memory corruption ● Questions 15 15 inequation.org inequation.org
  • 16. Right tool for the job Right tool for the job „Fix a bug for an intern, they will get stuck on the next one. Teach them debugging, they will fix most bugs they encounter on their own.” – Paulo Coelho 16 16 inequation.org inequation.org
  • 17. Right tool for the job Right tool for the job Debugging tools are essential to this profession! When joining a new team or starting development for a new platform, demand debugging tools ● Ask senior teammates ● If they don't know, there must be documentation ● Be proactive! ● Don't give up until the debugger is fully working ● No tools? Roll your own! ● You are a coder after all, right? ● 17 17 inequation.org inequation.org
  • 18. Right tool for the job Right tool for the job Not all bugs are in the code Animation graphs ● Flow graphs/visual scripts ● Post-process effects ● Still need a way to debug them 18 18 inequation.org inequation.org
  • 19. Right tool for the job Right tool for the job Code: 02-tools 19 19 inequation.org inequation.org
  • 20. Agenda Agenda ● Who is this guy? ● Why the talk? ● A taste of gamedev debugging ● Right tool for the job ● Noise filtering ● Memory corruption ● Questions 20 20 inequation.org inequation.org
  • 21. Noise filtering Noise filtering There are parts of code executed thousands of times each frame Object transformation ● Collision detection ● Also rarer, but still impractical to track Setting materials on objects ● Attaching and detaching of components ● 21 21 inequation.org inequation.org
  • 22. Noise filtering Noise filtering Code: 03-material 04-ragdoll 05-assert 22 22 inequation.org inequation.org
  • 23. Agenda Agenda ● Who is this guy? ● Why the talk? ● A taste of gamedev debugging ● Right tool for the job ● Noise filtering ● Memory corruption ● Questions 23 23 inequation.org inequation.org
  • 24. Memory corruption Memory corruption Look closely: // class declaration class Crasher extends ActorComponent; var int DummyArray[1024]; // in ammo consumption code Crash = new class'Crasher'; Comp = new class'ActorComponent' (Crash); 24 24 inequation.org inequation.org
  • 25. Memory corruption Memory corruption Look closely: // class declaration class Crasher extends ActorComponent; var int DummyArray[1024]; // in ammo consumption code Crash = new class'Crasher'; Comp = new class'ActorComponent' (Crash); 25 25 inequation.org inequation.org
  • 26. Memory corruption Memory corruption ● UnrealScript object construction syntax new <class> [(<template object>)]; ● But: sizeof(Crasher) > sizeof(ActorComponent) ● Verdict: 26 26 inequation.org inequation.org
  • 27. Memory corruption Memory corruption ● UnrealScript object construction syntax new <class> [(<template object>)]; ● But: sizeof(Crasher) > sizeof(ActorComponent) ● Verdict: 27 27 BUFFER OVERFLOW! inequation.org inequation.org
  • 28. Memory corruption Memory corruption But this can happen anywhere! How to find it? Use a memory fence ● Many related techniques ● Allocate additional space in front and behind actual allocations ● Then protect them from writing... ● Or write a byte pattern and periodically assert its consistency ● Also it's useful to log stack traces ● Memory and CPU overhead! ● Use a debug memory allocator (dmalloc) ● Use a memory debugger (Valgrind) ● Use a memory analysis tool (HeapInspector) ● 28 28 inequation.org inequation.org
  • 29. Memory corruption Memory corruption Memory fences malloc Regular allocation 29 29 malloc Fenced allocation inequation.org inequation.org
  • 30. Takeaway Takeaway You can't be an effective programmer without debugging tools ● If there are no tools, make some ● Noise filtering techniques save your time ● Time is not only money – nerves are just as important! ● Know your machine (physical or virtual) down to the metal ● Instruction opcodes, registers etc. come in handy ● Tons of resources available ● Random crashes and/or content glitches may indicate memory corruption ● Memory corruption can be defeated! ● 30 30 inequation.org inequation.org
  • 31. inequation.org inequation.org Questions? lg@inequation.org SpreadIT 2013 · October 19th, 2013 SpreadIT 2013 · October 19th, 2013