news.volyx.in

Debugging memory corruption: who the hell writes “2” into my stack? (2016) (blog.unity.com)

409 points by darknavi · 1772 days ago · 144 comments on HN

Article summary

A Unity developer shares a story of debugging a memory corruption bug that caused a game to crash. The bug was difficult to track down, but the developer eventually used a stack sentinel to identify the issue and kernel debugging to catch the culprit. The problem was caused by an exception being injected into a thread, corrupting the stack. The developer's approach to debugging and problem-solving is highlighted throughout the story.

Main themes

  • debugging
  • memory corruption
  • async IO
  • exception handling
  • Unity support
  • problem-solving
  • experience vs talent

What commenters say

  • Some commenters believe that using heap allocation instead of stack allocation could have prevented the crash, but others argue that it would have only masked the problem. The effectiveness of Unity's support team is questioned by some commenters, who have had negative experiences with them. Others defend the team, citing positive experiences and the challenges of supporting a large user base. The use of stack canaries or cookies is suggested as a potential solution to similar problems in the future. Some commenters note that the problem was not with the async IO itself, but with the exception being injected into the thread. The article is seen as an example of the importance of experience and wisdom in debugging and problem-solving, rather than just talent or intelligence. The challenges of debugging complex issues are highlighted, and the need for patience, persistence, and creative problem-solving is emphasized.