Skip to main content

Module 2: Memory, Pointers & Machine Representation: Mistake Clinic

This clinic turns wrong moves into reusable judgment. Use it after each practice page and again before the quiz or checkpoint.


Module-Specific Mistake Radar

Start with these traps. Replace or extend them with real mistakes from your own work.

Mistake to look forWhere it shows upSymptomRepair evidence
Finishing Bits and Representation Lab with only a final answerBits and Representation LabThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Pointers and Arithmetic Workshop with only a final answerPointers and Arithmetic WorkshopThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Memory Layout and Errors Clinic with only a final answerMemory Layout and Errors ClinicThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Finishing Code Katas with only a final answerCode KatasThe work has no failed case, trace, test, proof gap, or design stress point.Add the smallest broken example and show the repair that changes the result.
Treating Binary, Hex, and the Byte as the Unit of Access as vocabulary instead of a toolBinary, Hex, and the Byte as the Unit of AccessThe explanation names the concept but cannot decide between two cases.Write one example, one non-example, and the rule that separates them.
Treating Integer Representations: Unsigned, Two's Complement, Overflow as vocabulary instead of a toolInteger Representations: Unsigned, Two's Complement, OverflowThe explanation names the concept but cannot decide between two cases.Write one example, one non-example, and the rule that separates them.

Practice Mistake Checks

Pull any miss from these checks into your mistake log.

Bits and Representation Lab

Source: practice/01-bits-and-representation-lab.md

For each statement, identify the error:

  1. "for (unsigned i = n; i >= 0; i--) ... eventually terminates."
  2. "int x = INT_MAX + 1; gives INT_MIN on every C compiler."
  3. "float a = 0.1f + 0.1f + 0.1f; a == 0.3f is true because all values are small."
  4. "0xFF == -1 on a char."
  5. "Hex is a different number system from binary."

Pointers and Arithmetic Workshop

Source: practice/02-pointers-and-arithmetic-workshop.md

Identify the error in each line:

  1. char *s = "hello"; s[0] = 'H';
  2. int *p; *p = 10;
  3. int *f(void) { int x = 5; return &x; }
  4. int a[5]; memset(a, 0, 5);
  5. int a[5], *p = a; if (p + 10 < p) { ... }

Memory Layout and Errors Clinic

Source: practice/03-memory-layout-and-errors-clinic.md

For each program, predict the sanitizer / tool report before you run it:

  1. char b[8]; strcpy(b, "123456789");
  2. int *p = malloc(4 * sizeof *p); free(p); p[0] = 1;
  3. int *p = malloc(4 * sizeof *p); free(p); free(p);
  4. int *p = malloc(4 * sizeof *p); /* never freed */ return 0;
  5. int x; printf("%d\n", x); /* uninitialized read */

Repair Protocol

For each real mistake:

  1. Reproduce the failure on the smallest example, trace, proof, query, command, or design sketch.
  2. Name the hidden assumption.
  3. Repair the artifact.
  4. Save evidence that changed: failing then passing test, corrected proof step, revised diagram, safer command, benchmark, or review note.
  5. Add one retrieval card beginning with Check... before... or Do not use... when....

Mistake Log

DateMistakeSymptomRoot causeRepair evidenceRetrieval card
StarterPick one radar row aboveExplain how it would fail in this moduleName the assumptionAdd a counterexample or corrected artifactWrite the card before closing the page

Completion Standard

  • At least five real mistakes are logged.
  • At least two mistakes include a counterexample or failing test.
  • At least one mistake connects to an older semester skill.
  • At least one correction changes code, a proof, a diagram, a command transcript, a query, or a design decision.