|
|
Thursday I interviewed with a company in the Houston, Texas area.
One of the interviewers had me examine two pieces of buggy code and try
to identify the bugs. I don't remember all of the details. Here is the
first one:
function() {
// some stuff
if (whatever) {
// code here to get a mutex lock
// other stuff
}
// code here to release the mutex lock
// the rest of the function code
}
The way I simplified it makes it easier to spot the bug.
The second one was issued with the warning that very few people can id
the bug:
char* some_function() {
char yada[100];
char* p=yada;
// some stuff that fills the array with data
// and more stuff
// and more stuff
return p;
}
When I saw the return statement, and looked back to what the pointer was
set to, I said, "I wouldn't do that."
"Do what?" the interviewer asked.
"Return a pointer to a local variable."
This provoked a laugh from the interviewer.
Seriously? Not many people catch that?
Evidently not. In chatting with the interviewers that day, they all
confirmed that most bugs are stupid things like this.
Anyway, the job prospect is still a going affair, so I suppose I did
okay in the interview.
Regards,
John
Post a reply to this message
|
|