SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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 DevelopmentKarim Yaghmour
 
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.
 
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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 

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