Cisco Systems

  www.cisco.com
Work in HR? Unlock Free Profile

Cisco Systems Senior Software Engineer Interview Question

I interviewed in San Jose, CA and was asked:
"How would you debug Memory Corruption ?"
Add Tags [?]
Answer

Part of a Senior Software Engineer Interview Review - one of 1,063 Cisco Systems Interview Reviews

Answers & Comments

2
of 2
votes
Lots of answers to this one. There are some memory bounds-checker type tools, and it's not that complicated to write a basic one from scratch on a decent CPU.
Usually the tools override malloc/free/mmap/... and change them all to mmap protected memory with guard pages before and after the user region. Trying to access beyond the bounds of the region, trying to access a freed region will immediately result in a seg-fault.
Other than that, you can always put some guard data at the beginning and end of every structure and check them occasionally in your code. In many cases you'll be able to see the corrupt data before the program crashes and in some cases you might even be able to identify what data it is (hence where it came from), e.g. strings overriding other data.
- Boaz Sedan on Jun 9, 2010

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.