2. What is a bug?
● Basically, an error in a program
● When a program performs as it shouldn't
perform
● All software have bugs
– Programming is complex
– Human task -> errors
Master on Free Software
4. Bugfixing
● Find a bug
– By developers
– By users
● Report a bug
– Bugzilla
● Locate the problem
– Debugging tools
● Fix it
Master on Free Software
5. Finding bugs
● By developers
– Compile-time errors are not bugs!
– Running time
● By chance
● Running tests
● Using tools (see debugging)
● By users
– They don't look for, but bugs turn up!
– Reported to developers
● By testers
– Mix between developers and users
– Use more sophisticated techniques
Master on Free Software
6. Reporting bugs
● Crash-report applications
● Bugtrackers: issue tracker system
– Open a ticket (bug)
– Add comments and/or other stuff
– Tickets have states (life cycle)
– Close ticket (bug)
– Examples
● Bugzilla (from Mozilla Project)
● Mantis Bug Tracker
Master on Free Software
7. Finding the problem
● To find something, we need to know
about it
– Develop small tests to reproduce the problem
– Use debugging tools
● Debuggers
● Profilers
● Memory checkers
● ...
Master on Free Software
8. Fixing bugs
● Using input from the last point
● Verify tests perform fine
– Bug is fixed
– Not introduce new bugs
● Document and commit
Master on Free Software
9. Bugzilla
● Developed by Mozilla Foundation (1998)
● Web-based (LAMP)
● Widely used
● Highly configurable
Master on Free Software
14. Bugzilla
Bug description
Overview
Preconditions
Steps to reproduce
Actual results
Expected results
Frequency
Other relevant information
Master on Free Software
15. Bugzilla
● Priority: How urgent is to fix the bug?
● Differences between severity and priority
– Severity is a technical matter
– Priority is a business matter
– Severity is absolute
– Priority is relative
– Priority can be calculated from severity
Master on Free Software
18. Triagging
● Medical term: choose which patient would
receive medical cares
● Useful when there are a lot of bugs, but
few developers
– Share bugs among developers
– Use bug features and developers habilities to
assign the bugs
Master on Free Software
20. Bugzilla
From Bugzilla
Documentation
Master on Free Software
21. Some tools
● Printf ;-)
● GDB (GNU Debugger)
● Valgrind
● Electric Fence
● OProfile
● G_DEBUG (fatal_warnings, fatal_criticals)
Master on Free Software
22. OProfile
● Profile all running code
Master on Free Software
23. Electric Fence
● Find overflows / underflows
● Easy to use: preload/link against efence
library
● Mark with “red zones” buffers
– Crash inmediately when touching them
– Thus, errors don't turn up in a future time
Master on Free Software
24. G_DEBUG
● Useful to debug problems in Glib
● Environment variable
– fatal_criticals: g_critical generates a core
dump
– fatal_warnings: g_warning generates a core
dump
Master on Free Software
25. Valgrind
● Tool suite for debugging and profiling
● Simulates a x86 processor
– Memcheck: memory problems
● Memory accesses not allowed
● Memory leaks
● Bad frees
– Cachegrind: cache profiler
– Massif: heap profiler
– Helgrind: thread debugger
Master on Free Software
26. GDB
● GNU Debugger
● Text mode
– Other frontends: IDEs, emacs, DDD, XXGDB
● Trace the code
– See what is doing
– Inspect the data
Master on Free Software
27. GDB
● Requirements to debug an application
– Add debugging symbols -> not stripped
– Remove optimizations (-O0)
Master on Free Software
28. GDB
● How to use
– Run process with gdb
– Inspect core dumps
– Attach to running process
Master on Free Software
29. Core dumps
● Dump of information of a process when it
crashes
– See while it crashed
– Inspect data
● ulimit -c <size of core>
● ./gdb <program> <core>
Master on Free Software
30. GDB
● Run: runs the program from start
● Continue: continues running a stopped program
● Backtrace: show the stack
● Break: add a breakpoint
● Delete: delete a breakpoint
● Next: runs the current line to next
● Step: same as Next, but if current is a function, enter
inside
● Print: print the content of a variable
● Display: same as Print, but more permanent
Master on Free Software