morfizm (morfizm) wrote,
morfizm
morfizm

Nice bug

Just found a bug of this kind:

There are two group of objects: A and B. Each A has one or more Bs. The old code was written with the assumptions that B objects can be reused across As, by just moving pointers. New code broke this assumption by tieing it to the parent A and introducing a shared field with A (again, shared by pointer). So, the bug was in old code, which was correct under old assumptions, but incorrect under new ones.

I am not sure what's the right way to avoid this class of bugs as a whole. I'd just be extremely careful with reusing/sharing objects by pointers, and add a comment in class definition for every field where it's a case.
Tags: in english, software development
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 11 comments