How to be a Programmer
  • How to be a Programmer: Community Version
  • LANGS
  • How to be a Programmer: Community Version
    • Appendix A - Bibliography/Websiteography
    • Appendix B - History
    • Contributions
    • Glossary
    • Creative Commons Attribution Share-Alike
    • Summary
    • 1. Beginner
      • Personal-Skills
        • Learn to Debug
        • How to Debug by Splitting the Problem Space
        • How to Remove an Error
        • How to Debug Using a Log
        • How to Understand Performance Problems
        • How to Fix Performance Problems
        • How to Optimize Loops
        • How to Deal with I/O Expense
        • How to Manage Memory
        • How to Deal with Intermittent Bugs
        • How to Learn Design Skills
        • How to Conduct Experiments
      • Team-Skills
        • Why Estimation is Important
        • How to Estimate Programming Time
        • How to Find Out Information
        • How to Utilize People as Information Sources
        • How to Document Wisely
        • How to Work with Poor Code
        • How to Use Source Code Control
        • How to Unit Test
        • Take Breaks when Stumped
        • How to Recognize When to Go Home
        • How to Deal with Difficult People
    • 2. Intermediate
      • Judgment
        • How to Tradeoff Quality Against Development Time
        • How to Manage Software System Dependence
        • How to Decide if Software is Too Immature
        • How to Make a Buy vs. Build Decision
        • How to Grow Professionally
        • How to Evaluate Interviewees
        • How to Know When to Apply Fancy Computer Science
        • How to Talk to Non-Engineers
      • Mentoring
        • How to Be Mentored
        • How to Mentor Others
      • Personal-Skills
        • How to Stay Motivated
        • How to be Widely Trusted
        • How to Tradeoff Time vs. Space
        • How to Stress Test
        • How to Balance Brevity and Abstraction
        • How to Learn New Skills
        • Learn to Type
        • How to Do Integration Testing
        • Communication Languages
        • Heavy Tools
        • How to analyze data
      • Team-Skills
        • How to Manage Development Time
        • How to Manage Third-Party Software Risks
        • How to Manage Consultants
        • How to Communicate the Right Amount
        • How to Disagree Honestly and Get Away with It
    • 3. Advanced
      • Compromising-Wisely
        • How to Fight Schedule Pressure
        • How to Understand the User
        • How to Get a Promotion
      • Serving-Your-Team
        • How to Develop Talent
        • How to Choose What to Work On
        • How to Get the Most From Your Team-mates
        • How to Divide Problems Up
        • How to Handle Boring Tasks
        • How to Gather Support for a Project
        • How to Grow a System
        • How to Communicate Well
        • How to Tell People Things They Don't Want to Hear
        • How to Deal with Managerial Myths
        • How to Deal with Organizational Chaos
      • Technical-Judgment
        • How to Tell the Hard From the Impossible
        • How to Utilize Embedded Languages
        • Choosing Languages
  • Cómo ser un Programador: Versión Comunitaria
    • Apéndice A - Bibliografía/Sitografía
    • Apéndice B - Historia
    • Contribuciones
    • Glossary
    • Licencia Creative Commons Atribución-CompartirIgual
    • Resumen
    • 1. Principiante
      • Personal-Skills
        • Aprende a depurar
        • ¿Cómo depurar dividiendo el espacio del problema?
        • ¿Cómo eliminar un error?
        • ¿Cómo depurar utilizando un registro (Log)?
        • ¿Cómo entender problemas de rendimiento?
        • ¿Cómo solucionar problemas de rendimiento?
        • ¿Cómo optimizar bucles?
        • ¿Cómo manejar el costo de la entrada/salida (E/S)?
        • ¿Cómo gestionar la memoria?
        • ¿Cómo manejar errores intermitentes?
        • ¿Cómo aprender habilidades de diseño?
        • ¿Cómo realizar experimentos?
      • Team-Skills
        • ¿Por qué es importante la estimación?
        • ¿Cómo estimar el tiempo de programación?
        • ¿Cómo encontrar información?
        • ¿Cómo utilizar a las personas como fuentes de información?
        • ¿Cómo documentar de manera inteligente?
        • ¿Cómo trabajar con un código deficiente?
        • ¿Cómo Utilizar el Control de Código Fuente?
        • ¿Cómo realizar pruebas unitarias?
        • Tomarse descansos cuando te sientes bloqueado
        • ¿Cómo reconocer cuándo es hora de ir a casa?
        • ¿Cómo lidiar con personas difíciles?
    • 2. Intermedio
      • Judgment
        • ¿Cómo equilibrar la calidad contra el tiempo de desarrollo?
        • ¿Cómo gestionar la dependencia del sistema de software?
        • ¿Cómo decidir si el software es demasiado inmaduro?
        • ¿Cómo tomar una decisión de compra frente a desarrollo interno?
        • ¿Cómo crecer profesionalmente?
        • ¿Cómo evaluar a los candidatos en una entrevista?
        • ¿Cómo saber cuándo aplicar conceptos avanzados de ciencias de la computación?
        • ¿Cómo hablar con personas no ingenieras?
      • Personal-Skills
        • ¿Cómo mantenerse motivado?
        • ¿Cómo ser ampliamente confiado?
        • ¿Cómo hacer equilibrio entre tiempo y espacio?
        • ¿Cómo realizar pruebas de resistencia?
        • ¿Cómo equilibrar brevedad y abstracción?
        • ¿Cómo aprender nuevas habilidades?
        • Aprender a escribir
        • ¿Cómo hacer pruebas de integración?
        • Idiomas de comunicación
        • Herramientas pesadas
        • ¿Cómo analizar datos?
      • Team-Skills
        • ¿Cómo gestionar el tiempo de desarrollo?
        • ¿Cómo gestionar los riesgos del software de terceros?
        • ¿Cómo gestionar a los consultores?
        • ¿Cómo comunicar la cantidad adecuada?
        • ¿Cómo disentir honradamente y salir airosos?
    • 3. Avanzado
      • Compromising-Wisely
        • ¿Cómo Combatir la Presión del Cronograma?
        • ¿Cómo Entender al Usuario?
        • ¿Cómo Obtener un Ascenso?
      • Serving-Your-Team
        • ¿Cómo Desarrollar el Talento?
        • ¿Cómo Elegir en Qué Trabajar?
        • ¿Cómo Obtener lo Mejor de tus Compañeros de Equipo?
        • ¿Cómo Dividir Problemas?
        • ¿Cómo Manejar Tareas Aburridas?
        • ¿Cómo Obtener Apoyo para un Proyecto?
        • ¿Cómo Hacer Crecer un Sistema?
        • ¿Cómo Comunicarse Bien?
        • ¿Cómo Decir Cosas que la Gente no Quiere Escuchar?
        • ¿Cómo Lidiar con Mitos Gerenciales?
        • ¿Cómo Lidiar con el Caos Organizacional?
      • Technical-Judgment
        • ¿Cómo Distinguir lo Difícil de lo Imposible?
        • ¿Cómo Utilizar Lenguajes Incorporados?
        • Elección de Lenguajes
  • How to be a Programmer: Community Version
    • Appendix A - Bibliography/Websiteography
    • Appendix B - History
    • Contributions
    • Glossary
    • Creative Commons Attribution Share-Alike
    • Summary
    • 1. Beginner
      • Personal-Skills
        • Learn to Debug
        • How to Debug by Splitting the Problem Space
        • How to Remove an Error
        • How to Debug Using a Log
        • How to Understand Performance Problems
        • How to Fix Performance Problems
        • How to Optimize Loops
        • How to Deal with I/O Expense
        • How to Manage Memory
        • How to Deal with Intermittent Bugs
        • How to Learn Design Skills
        • How to Conduct Experiments
      • Team-Skills
        • Why Estimation is Important
        • How to Estimate Programming Time
        • How to Find Out Information
        • How to Utilize People as Information Sources
        • How to Document Wisely
        • How to Work with Poor Code
        • How to Use Source Code Control
        • How to Unit Test
        • Take Breaks when Stumped
        • How to Recognize When to Go Home
        • How to Deal with Difficult People
    • 2. Intermediate
      • Judgment
        • How to Tradeoff Quality Against Development Time
        • How to Manage Software System Dependence
        • How to Decide if Software is Too Immature
        • How to Make a Buy vs. Build Decision
        • How to Grow Professionally
        • How to Evaluate Interviewees
        • How to Know When to Apply Fancy Computer Science
        • How to Talk to Non-Engineers
      • Personal-Skills
        • How to Stay Motivated
        • How to be Widely Trusted
        • How to Tradeoff Time vs. Space
        • How to Stress Test
        • How to Balance Brevity and Abstraction
        • How to Learn New Skills
        • Learn to Type
        • How to Do Integration Testing
        • Communication Languages
        • Heavy Tools
        • How to analyze data
      • Team-Skills
        • How to Manage Development Time
        • How to Manage Third-Party Software Risks
        • How to Manage Consultants
        • How to Communicate the Right Amount
        • How to Disagree Honestly and Get Away with It
    • 3. Advanced
      • Compromising-Wisely
        • How to Fight Schedule Pressure
        • How to Understand the User
        • How to Get a Promotion
      • Serving-Your-Team
        • How to Develop Talent
        • How to Choose What to Work On
        • How to Get the Most From Your Team-mates
        • How to Divide Problems Up
        • How to Handle Boring Tasks
        • How to Gather Support for a Project
        • How to Grow a System
        • How to Communicate Well
        • How to Tell People Things They Don't Want to Hear
        • How to Tell People Things They Don't Want to Hear
        • How to Deal with Managerial Myths
        • How to Deal with Organizational Chaos
      • Technical-Judgment
        • How to Tell the Hard From the Impossible
        • How to Utilize Embedded Languages
        • Choosing Languages
  • Как быть программистом: Community Version
    • Приложение A - Библиография/Список сайтов
    • Приложение B - История
    • Участие в проекте
    • Глоссарий
    • Creative Commons Attribution Share-Alike
    • Содержание
    • 1. Начинающий программист
      • Personal-Skills
        • Научитесь отлаживать
        • Как отлаживать, разделяя пространство проблемы
        • Как устранять баги
        • Как отлаживать, используя логи
        • Как определять проблемы производительности
        • Как устранять проблемы производительности
        • Как оптимизировать циклы
        • Как справиться с расходами на операции чтения и записи
        • Как управлять памятью
        • Как устранять плавающие баги
        • Как научиться проектировать программы
        • Как экспериментировать
      • Team-Skills
        • Почему важно оценивать задачи
        • Как оценивать время на разработку
        • Как искать информацию
        • Как спрашивать людей
        • Как документировать правильно
        • Как работать с плохим кодом
        • Как использовать системы контроля версий
        • Как писать юнит-тесты
        • Делайте перерывы, когда вы в тупике
        • Как понять, когда идти домой
        • Как вести себя с трудными людьми
    • 2. Программист среднего уровня
      • Judgment
        • Как балансировать качество и время разработки
        • Как управлять зависимостями
        • Как оценивать стороннее программное обеспечение
        • Как решить: покупать программу или писать свою
        • Как расти профессионально
        • Как проводить собеседования
        • Как понять, когда применять высокие технологии
        • Как разговаривать с неинженерами
      • Personal-Skills
        • Как сохранять мотивацию
        • Как заслужить доверие
        • Как балансировать процессорное время и память
        • Как проводить стресс-тестирование
        • Как балансировать краткость и абстракцию
        • Как осваивать новые навыки
        • Научитесь печатать вслепую
        • Как проводить интеграционное тестирование
        • Языки взаимодействия систем
        • Стандартные технологии
        • Как анализировать данные
      • Team-Skills
        • Как управлять временем разработки
        • Как управлять рисками, связанными со сторонним программным обеспечением
        • Как руководить консультантами
        • Как соизмерять количество общения
        • Как честно выражать несогласие
    • 3. Продвинутый программист
      • Compromising-Wisely
        • Как справляться с давлением графика
        • Как понять пользователя
        • Как получить повышение
      • Serving-Your-Team
        • Как развивать таланты
        • Как выбрать, над чем работать
        • Как получить наибольшую отдачу от коллег
        • Как разделять задачи
        • Как распределять скучные задания
        • Как получить поддержку для проекта
        • Как развивать систему
        • Как качественно взаимодействовать
        • Как сообщать неприятное
        • Как справляться с менеджерскими мифами
        • Как справляться с организационным хаосом
      • Technical-Judgment
        • Как отличить сложное от невозможного
        • Как использовать встроенные языки
        • Выбор языка программирования
  • How to be a Programmer 中文版
    • 词汇表
    • 附录 A - 书目/网站目录
    • 附录 B - 历史
    • Contributions
    • Creative Commons Attribution Share-Alike
    • How to be a Programmer 正體中文版
    • 1. 入门
      • Personal-Skills
        • 學習除錯
        • 如何通过分割问题 Debug
        • 如何移除一个错误
        • 如何使用日志调试
        • 如何理解性能问题
        • 如何修复性能问题
        • 如何优化循环
        • 如何处理I/O代价
        • 如何管理内存
        • 如何处理偶现的 Bugs
        • 如何学习设计技能
        • 如何进行实验
      • Team-Skills
        • 为什么评估很重要
        • 如何评估编程时间
        • 如何发现信息
        • 如何把人们作为信息源
        • 如何睿智地写文档
        • 如何在糟糕的代码上工作
        • 如何使用源代码控制
        • 如何进行单元测试
        • 毫无头绪?,休息一下
        • 如何识别下班时间
        • 如何与不好相处的人相处
    • 2. 进阶
      • Judgment
        • 如何在开发质量与开发时间权衡
        • 如何管理软件系统依赖
        • 如何判断软件是否太不成熟了
        • 如何做购买还是构建的决定
        • 如何专业地成长
        • 如何评估面试者
        • 如何决定什么时候使用奇妙的计算机科学
        • 如何与非工程师交谈
      • Personal-Skills
        • 如何保持活力
        • 如何被广泛信任
        • 如何在时间与空间权衡
        • 如何进行压力测试
        • 如何在简洁与抽象间平衡
        • 如何学习新技能
        • 学会打字
        • 如何做集成测试
        • 交流语言
        • 重型工具
        • 如何分析数据
      • Team-Skills
        • 如何管理开发时间
        • 如何管理第三方软件危机
        • 如何管理咨询师
        • 如何适量交流
        • 如何直言异议以及如何避免
    • 3. 高级
      • Compromising-Wisely
        • 如何与时间压力做斗争
        • 如何理解用户
        • 如何获得晋升
      • Serving-Your-Team
        • 如何发展才能
        • 如何选择工作的内容
        • 如何让你队友的价值最大化
        • 如何划分问题
        • 如何处理无聊的任务
        • 如何为工程获取支持
        • 如何发展一个系统
        • 如何有效地沟通
        • 如何告诉人们他们不想听的东西
        • 如何处理管理神话
        • 如何处理组织混乱
      • Technical-Judgment
        • 如何从不可能中找到困难的部分
        • 如何使用嵌入型语言
        • 选择语言
  • How to be a Programmer 中文版
    • 词汇表
    • 附录 A - 书目/网站目录
    • 附录 B - 历史
    • Contributions
    • Creative Commons Attribution Share-Alike
    • How to be a Programmer 中文版
    • 1. 入门
      • Personal-Skills
        • 学会 Debug
        • 如何通过分割问题 Debug
        • 如何移除一个错误
        • 如何使用日志调试
        • 如何理解性能问题
        • 如何修复性能问题
        • 如何优化循环
        • 如何处理I/O代价
        • 如何管理内存
        • 如何处理偶现的 Bugs
        • 如何学习设计技能
        • 如何进行实验
      • Team-Skills
        • 为什么评估很重要
        • 如何评估编程时间
        • 如何发现信息
        • 如何把人们作为信息源
        • 如何睿智地写文档
        • 如何在糟糕的代码上工作
        • 如何使用源代码控制
        • 如何进行单元测试
        • 毫无头绪?,休息一下
        • 如何识别下班时间
        • 如何与不好相处的人相处
    • 2. 进阶
      • Judgment
        • 如何在开发质量与开发时间权衡
        • 如何管理软件系统依赖
        • 如何判断软件是否太不成熟了
        • 如何做购买还是构建的决定
        • 如何专业地成长
        • 如何评估面试者
        • 如何决定什么时候使用奇妙的计算机科学
        • 如何与非工程师交谈
      • Personal-Skills
        • 如何保持活力
        • 如何被广泛信任
        • 如何在时间与空间权衡
        • 如何进行压力测试
        • 如何在简洁与抽象间平衡
        • 如何学习新技能
        • 学会打字
        • 如何做集成测试
        • 交流语言
        • 重型工具
        • 如何分析数据
      • Team-Skills
        • 如何管理开发时间
        • 如何管理第三方软件危机
        • 如何管理咨询师
        • 如何适量交流
        • 如何直言异议以及如何避免
    • 3. 高级
      • Compromising-Wisely
        • 如何与时间压力做斗争
        • 如何理解用户
        • 如何获得晋升
      • Serving-Your-Team
        • 如何发展才能
        • 如何选择工作的内容
        • 如何让你队友的价值最大化
        • 如何划分问题
        • 如何处理无聊的任务
        • 如何为工程获取支持
        • 如何发展一个系统
        • 如何有效地沟通
        • 如何告诉人们他们不想听的东西
        • 如何处理管理神话
        • 如何处理组织混乱
      • Technical-Judgment
        • 如何从不可能中找到困难的部分
        • 如何使用嵌入型语言
        • 选择语言
  • 2-Intermediate
    • Judgment
      • Design Patterns
Powered by GitBook
On this page

Was this helpful?

  1. How to be a Programmer: Community Version
  2. 1. Beginner
  3. Personal-Skills

How to Deal with Intermittent Bugs

PreviousHow to Manage MemoryNextHow to Learn Design Skills

Last updated 5 years ago

Was this helpful?

The intermittent bug is a cousin of the 50-foot-invisible-scorpion-from-outer-space kind of bug. This nightmare occurs so rarely that it is hard to observe, yet often enough that it can't be ignored. You can't debug because you can't find it.

Although after 8 hours you will start to doubt it, the intermittent bug has to obey the same laws of logic everything else does. What makes it hard is that it occurs only under unknown conditions. Try to record the circumstances under which the bug does occur, so that you can guess what the variability really is. The condition may be related to data values, such as ‘This only happens when we enter Wyoming as a value.’ If that is not the source of variability, the next suspect should be improperly synchronized concurrency.

Try, try, try to reproduce the bug in a controlled way. If you can't reproduce it, set a trap for it by building a logging system, a special one if you have to, that can log what you guess you need when it really does occur. Resign yourself to that if the bug only occurs in production and not at your whim, this may be a long process. The hints that you get from the log may not provide the solution but may give you enough information to improve the logging. The improved logging system may take a long time to be put into production. Then, you have to wait for the bug to reoccur to get more information. This cycle can go on for some time.

The stupidest intermittent bug I ever created was in a multi-threaded implementation of a functional programming language for a class project. I had very carefully ensured correct concurrent evaluation of the functional program, good utilization of all the CPUs available (eight, in this case). I simply forgot to synchronize the garbage collector. The system could run a long time, often finishing whatever task I began, before anything noticeable went wrong. I'm ashamed to admit I had begun to question the hardware before my mistake dawned on me.

At work we recently had an intermittent bug that took us several weeks to find. We have multi-threaded application servers in Java™ behind Apache™ web servers. To maintain fast page turns, we do all I/O in small set of four separate threads that are different than the page-turning threads. Every once in a while these would apparently get ‘stuck’ and cease doing anything useful, so far as our logging allowed us to tell, for hours. Since we had four threads, this was not in itself a giant problem - unless all four got stuck. Then the queues emptied by these threads would quickly fill up all available memory and crash our server. It took us about a week to figure this much out, and we still didn't know what caused it, when it would happen, or even what the threads where doing when they got ‘stuck’.

This illustrates some risk associated with third-party software. We were using a licensed piece of code that removed HTML tags from text. Although we had the source code (thank goodness!) we had not studied it carefully until by turning up the logging on our servers we finally realized that the email threads were getting stuck in this problematic licensed code.

The program performed well except on some long and unusual kinds of texts. On these texts, the code was quadratic or worse. This means that the processing time was proportional to the square of the length of the text. Had these texts occurred commonly, we would have found the bug right away. If they had never occurred at all, we would never have had a problem. As it happens, it took us weeks to finally understand and resolve the problem.

Next

How to Learn Design Skills