0Pricing
C Academy · Lesson

Reading Reports

Interpret output.

Reading Reports is a free C Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Anatomy Of A Report

A Valgrind report has three parts:

  • The process ID prefix on every line
  • One or more error blocks as they occur
  • A final HEAP and LEAK SUMMARY at exit

Learning to read each part turns a wall of text into a precise to-do list.

The PID Prefix

Every Valgrind line starts with ==PID==, for example ==12345==.

This is the process ID, not part of your program's output. It lets you separate Valgrind's messages from your program's printf when both share the terminal.

==12345== Memcheck, a memory error detector
==12345== Command: ./prog
==12345==

A Sample Error Block

Here is a real invalid-write block:

==12345== Invalid write of size 4
==12345== at 0x4005A1: main (prog.c:6)
==12345== Address 0x520304c is 0 bytes after a block of size 20 alloc'd
==12345== at 0x4838B40: malloc
==12345== by 0x40058E: main (prog.c:5)

Read The First Line

The first line names the error kind and size: 'Invalid write of size 4'.

Size 4 means a 4-byte access, typically an int. This single line tells you what category of bug to expect before you read any further.

Read The Stack Trace

The at line is the innermost frame, where the error happened. Each by line is a caller, one level up.

Read top to bottom as deepest to shallowest. The first frame with your file name is almost always the bug site.

==12345==    at 0x4005A1: do_work (work.c:12)
==12345==    by 0x4006F0: main (main.c:8)

Read The Address Note

The Address ... line locates the access relative to a known block:

  • 0 bytes after a block of size 20 alloc'd — overflow just past the end
  • 4 bytes inside a block of size 4 free'd — use after free
  • on thread 1's stack — a stack access

It even shows where that block was allocated or freed.

The HEAP SUMMARY

At exit you get allocation accounting:

==12345== HEAP SUMMARY:
==12345== in use at exit: 20 bytes in 1 blocks
==12345== total heap usage: 3 allocs, 2 frees, 1,044 bytes allocated

'in use at exit' greater than zero means something was not freed.

The LEAK SUMMARY

Below the heap summary, leaks are bucketed:

definitely lost: 20 bytes in 1 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 0 bytes in 0 blocks

Add --leak-check=full to attach a trace to each lost block.

The ERROR SUMMARY

The very last line counts everything:

ERROR SUMMARY: 2 errors from 2 contexts

A 'context' is a unique error location. If a buggy line runs in a loop a million times, it is still one context. Your goal is 0 errors from 0 contexts.

Triage Order

Work the report methodically:

  • Fix invalid access errors first; they cause corruption
  • Then uninitialized value errors
  • Then definitely and indirectly lost leaks
  • Re-run after each fix; one root cause often clears several reports

Suppressing Known Noise

Some errors come from libraries you cannot fix, like the C runtime or a graphics driver. Generate a suppression file to silence those without hiding your own bugs.

--gen-suppressions=all prints ready-to-use suppression entries you save and pass back with --suppressions=file.

valgrind --gen-suppressions=all ./prog
valgrind --suppressions=mine.supp ./prog

Quick Check

Interpret one line of a report.

Recap

You can now read Valgrind reports end to end:

  • ==PID== prefixes Valgrind lines, separating them from program output
  • Each error block gives kind, size, stack trace, and an address note
  • HEAP/LEAK summaries account for allocations and lost memory
  • ERROR SUMMARY counts unique contexts; aim for zero

Triage access errors first, then leaks, re-running as you go.

Frequently asked questions

Is the “Reading Reports” lesson free?

Yes — the full text of “Reading Reports” is free to read here on the web, and the C Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C Academy course, upgrade to CoddyKit PRO.

What will I learn in “Reading Reports”?

Interpret output. You practise C Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start C Academy?

No prior experience is required. C Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Reading Reports” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this C Academy lesson?

Yes. Every C Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Why Valgrind
  2. Detecting Leaks
  3. Invalid Access
  4. Reading Reports
← Back to C Academy