Reply to post: So many, but my favorite

You've seen things people wouldn't believe – so tell us your programming horrors

Mike 16

So many, but my favorite

was debugging what looked like a networking problem on a multi-player game.

First step: compile with debug enabled, install on one node.

Next step: scratch head as _everything_ falls over.

Look at user code, which did what amounted to a Remote Procedure Call by slopping a struct into a datagram and sending it. The first field of the struct was a function pointer, so the receive routine was essentially

Grab four bytes from the head of the datagram.

JSR to the code at that address, passing a pointer to the remainder.

On return, build a reply packet with the (integer only) return value, and send it back.

This "works" when every node is running exactly the same code. Not so much when foo() on one node is at a different address than foo() on another. Like, say, if the debug compile disables some optimization and code shifts.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon