October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How Do You Debug Something That Is Allowed to Be Wrong?

Debugging software that is allowed to be wrong means defining the tolerated error first, measuring it across representative inputs, and using runtime checks and a debugger to explain violations.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You debug it against a written contract that states how wrong the program may be, for which inputs, and how often. Without that contract, “it’s allowed to be wrong” becomes an excuse for defects you cannot explain. With it, debugging becomes a measurement problem: check observed behavior against the tolerance, add runtime checks where failures matter in service, and use a debugger to find out why a violation happens.

Passing a handful of test cases, or finding a plausible local fix, does not show that a probabilistic or approximate program meets its target. The rest of this article explains how to build that contract and what to do when the program falls outside it.

Start with the question Adrian Sampson asks

Adrian Sampson’s 2016 essay “Probably Correct” frames the problem directly: how do you know whether a program is good enough if it is allowed to be wrong some of the time? He calls the underlying idea statistical correctness, meaning an evaluation of whether a program is good enough even when it is not always correct (Sampson, “Probably Correct,” 15 June 2016). The essay is useful because it refuses to define “good” in advance. As Sampson puts it:

The word good is intentionally vague: it might mean something about the output f writes to a file, or about how fast f runs, or whether f violated some security policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

That vagueness is the real starting point. A program that renders approximate images, ranks search results, or runs a sensor model can be “wrong” in several different ways, and each way needs its own tolerance. Debugging begins once you have chosen which way matters.

Step one: write the contract before you touch the code

A usable contract has four parts. Each one answers a question that a debugger cannot answer for you.

Rank #2
Panvola Debugging Definition Programmer Gift Mug 11oz Black
  • Debugging Definition: It's about time they know who they really are: being the detective and the murderer in a crime movie at the same time. You can see them staring and typing away cryptic stuff for hours sometimes more, trying to plan how to find and murder that bug.
Contract element Question it answers Hypothetical entry for an image-compression step
Quality measure What counts as a correct output? A perceptual similarity score against a reference render
Input population Which inputs must the guarantee cover? Photos up to 4000 × 3000 pixels from the production upload queue
Tolerance How wrong may an output be, and how often? Score below the agreed threshold in no more than a rate the team has chosen and written down
Hard limits Which failures are never acceptable? Leaking metadata from a private upload, regardless of image quality

The table is hypothetical; Sampson’s essay does not supply any of these values, and the numbers in a real contract come from the application’s requirements and risk. Two points deserve emphasis.

Name the quality measure explicitly

“Good enough” is not a metric. Pick something you can compute for each output, whether that is an accuracy score, a latency bound, a comparison against a reference, or a policy check. If the output is a file, measure the file. If the concern is speed, measure time. Sampson’s point is that the measure follows from what the program is meant to do.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate tolerated errors from unacceptable failures

Some errors are a matter of degree: a slightly blurrier image or a ranking that swaps two near-equal results. Others are binary: exposing private data, violating a security policy, or corrupting a stored record. Put the second category in its own list with a zero-tolerance rule. Mixing the two produces the common mistake of treating a security violation as a quality issue that a good average can offset.

Why a few passing examples cannot settle the question

Once a tolerance exists, the evidence has to match it. If the claim is about a population of inputs, a set of successful examples is evidence only about those examples. Statistical correctness shifts the question from “did this input work?” to “what fraction of inputs in this population meet the criterion, and where do the failures cluster?”

Rank #4
Sale
Panvola Debugging Definition Tech Support Gifts Programmer Tumbler 30oz
  • Debugging Definition: It's about time they know who they really are: being the detective and the murderer in a crime movie at the same time. You can see them staring and typing away cryptic stuff for hours sometimes more, trying to plan how to find and murder that bug.
  • Vacuum-Insulated Stainless Steel Tumbler: This travel tumbler maintains the temperature of your favorite hot or cold beverage like a champ, thanks to its double-wall insulation. It is vacuum insulated for 2X cold and heat retention compared to glass or plastic containers. Uses food-grade stainless steel very safe to use. The removable clear lid can keep your drink's temperature for extended hours making you enjoy your drink more. Perfect to use at home, kitchen, office, work, or school.
  • Relatable Humorous Quote: Put a smile on their face with this Debugging Definition Tumbler. This insulated tumbler has a funny relatable quote that can make any programmer smile while sipping his or her favorite drinks. A stressful work day can also be fun with this drinkware on their dining or work table. A perfect conversation starter, and sure to amuse anyone. Trust us, you'll want this for yourself if you are a coder yourself.
  • Funny Gift: Perfect affordable present to your boyfriend, dad, husband, brother, uncle, or friend who is a coder, programming student or teacher, co-worker, classmate, or boss. Best item for birthdays, Valentine’s, graduation, holidays, wedding anniversaries, Christmas, work events, or any special milestone that occurs in life. Great item for your friends and family member who can relate to this good message and make them smile every time they use it.
  • Top Grade Quality: Drinks stay cold for 24 hours and hot for 12 hours perfect for on-the-go hydration. Has a premium powder coat that provides crisp and vibrant color reproduction, it will always look brand new even for years. Double-wall insulation keeps the exterior sweat-free so you won't have to worry about the tumbler becoming slippery when holding, your bags stay dry, or leaving water rings on your table. We use food-grade 304 Stainless Steel BPA-free, will not rust and are safe to use.

This has practical consequences:

  • Record every observation with its input, output, and a pass or fail judgment against the contract, not just the failures you noticed.
  • Include deliberately hard inputs, such as unusual sizes, extreme values, or edge conditions you already suspect, so that weak spots are not hidden by an easy sample.
  • Report the rate along with the cases behind it. A rate without a breakdown by input type can conceal a region where the program fails badly.
  • Do not infer a population-wide claim from a small sample without addressing sampling and uncertainty. Sampson’s framing supports the statistical view but does not prescribe a sample size, so choose one that fits the stakes and say how you chose it.

Testing and runtime checks answer different questions

Sampson describes two ways to enforce statistical correctness. The first is a testing analogy: evaluate behavior on selected cases and treat the results as evidence about the program’s correctness. The second is runtime checking: move the check into execution so that the program’s behavior is evaluated as it runs. The article describes the runtime approach as giving a stronger guarantee.

Comparison axis Testing analogy Runtime checking
When the check runs Before release or in a test harness During execution, in service
Which inputs it observes The cases you chose The inputs the program actually receives
Kind of guarantee Evidence from chosen cases A runtime guarantee, which Sampson describes as stronger
Runtime cost and operational complexity Not quantified in Sampson’s essay; depends on the application Not quantified in Sampson’s essay; depends on the application

In practice you usually need both. Tests tell you whether the program is likely to meet its target before you ship it. Runtime checks tell you whether it is meeting the target on real traffic, and they make violations visible when the test population turns out to differ from production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Panvola Stages Of Debugging Computer Programmer Gift Funny Programming Mug For Dad Husband Boyfriend Coworker From Wife Girlfriend Friends 11 oz White Coffee Cup
  • ULTIMATE GIFT MUG THAT STANDS OUT FROM THE REST: Do you spend your days debugging code and your nights dreaming about syntax errors? Then you know that debugging is a process that can take you on an emotional rollercoaster. That's why we created the "6 Stages of Debugging" mug - to help you laugh through the pain. Just don't blame us if you start talking to your code like it's a person - we've all been there.
  • PREMIUM CERAMIC COFFEE MUG: This high-quality 11oz ceramic mug has a premium hard coat that provides crisp and vibrant color reproduction sure to last for years. Printed on both sides for either left or right-handed person so the awesome message and art will be visible. High-gloss and has a premium finish that can make you enjoy your drink more. Can also be used as pen holders on your office work table, planter for your kitchen herb, jewelry holder, or serving your favorite dessert.
  • RELATABLE HUMOROUS QUOTE: Why settle for a boring old mug when you can have this one-of-a-kind drinkware on your dining, kitchen, or work table? Bring a smile to your loved ones' faces with this hilarious mug. Featuring a witty and relatable quote, this mug is sure to brighten anyone's day. Whether you're enjoying your morning coffee or taking a well-deserved break at work, this mug is the perfect pick-me-up. A conversation starter, it's also a surefire way to lift anyone's mood.
  • HILARIOUS AND QUIRKY GIFT MUG: A great gift for anyone who works in software development or coding, especially those who have a good sense of humor about the ups and downs of debugging. It could also be a fun gift for anyone who enjoys programming or technology-related humor, even if they're not a professional coder.
  • DISHWASHER AND MICROWAVE SAFE: These fantastic drinking mugs can go straight in the dishwasher, all day every day, meaning it can save you time, and be more hygienic. Perfect for your favorite hot or cold beverages. Easily reheat that coffee or tea you forgot to drink right away because it is microwave safe. Saves you time, is very convenient, and is perfect for your busy lifestyle.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When observed behavior violates the contract: debugging with GDB

A violation tells you that the program is outside its tolerance. It does not tell you why. For that, a conventional debugger is still the right tool. The GNU Debugger (GDB) manual, maintained as living documentation at Debugging with GDB, describes starting a program, stopping on conditions, examining state, and experimenting with changes. Those capabilities help you locate the cause of a violation. Deciding whether the resulting behavior is acceptable remains the job of the contract.

A diagnostic sequence

  1. Reproduce the violation. Save the input that produced the failing output. If the failure is intermittent, log enough state to replay the same input later.
  2. Start the program under GDB. Run gdb ./your-program, then run with the saved input as arguments or via a file redirect.
  3. Stop at the relevant location or condition. Use break file.c:42 for a line, or add a condition such as break score_output if score < 0.8 so the program pauses only when the suspect situation occurs.
  4. Inspect state. Use print variable to examine values and backtrace to see how execution reached that point.
  5. Experiment with a correction. Use set var variable = value to test whether changing a value at that point restores acceptable behavior, then continue to see the downstream effect.
  6. Make the change in source code and rebuild. A value tweak in the debugger proves only that the variable matters; the fix still has to be written and measured.

The GDB command names above are standard, but exact behavior can vary with compiler flags and debugger version. The manual is the authoritative reference for the commands in your environment.

Re-run the statistical check after every change

A fix for one failing case can move error elsewhere. Tightening a threshold may reduce one kind of error while increasing another, and a change that speeds the program may lower output quality on hard inputs. After any change, rerun the same measurement against the same input population and compare rates by category, not only the headline number.

Keep ordinary deterministic tests too. They catch regressions in code paths that have nothing to do with approximation, such as crashes, malformed output, or broken interfaces. The statistical check does not replace them; it sits beside them as the release criterion for the behavior the contract covers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting: when the numbers do not behave

  • The overall rate meets the target, but one input group fails. Break the measurement down by input type. A passing average can hide a population the contract is supposed to cover; either fix that group or narrow the contract explicitly.
  • The failures seem random. Log seeds, input hashes, and relevant state so the failing case can be replayed. Random-looking behavior is often deterministic once inputs are recorded.
  • A hard-limit violation appears. Treat it as a defect, not a tolerance question. Stop the release, reproduce it, and fix it before measuring quality again.
  • Runtime checks are expensive. Sample a fraction of production traffic, check the most sensitive outputs first, and record the cost so the trade-off is visible rather than assumed.

What the contract cannot tell you

Sampson’s essay establishes the framing, not the numbers. It does not give a universal error threshold, a sample size, or a domain-specific safety policy. Those must come from the application’s requirements, its users, and the consequences of a miss. If the contract is vague, the debugging will be vague too, no matter how good the tools are.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.