Menu

Placement new support

2019-06-28
2019-06-29
  • Nick Ridgway

    Nick Ridgway - 2019-06-28

    I recently found a false-negative bug in the checker for unsafeClassCanLeak that was caused by the fact that placement new was used to allocate the member that should have caused the warning. It could be that there are more checkers that look for uses of new that wouldn't match a placement new, do you know how likely it is that more checkers are affected by this? Would it be worth the effort to find and fix them all?

     
    • Daniel Marjamäki

      hmm.. we need to be careful about placement new

      I have the feeling we've had 2-3 false positive reports with that.
      Here is one ticket:
      https://trac.cppcheck.net/ticket/7163

      I believe a related problem is that basically we do not handle when
      more than one pointer points at the allocated memory.. if both
      pointers can free the memory. No leak is reported here:

      void f() {
          void *p = malloc(10);
          void *p2 = p;  // <- leaks checking of "p" bails out here
      }
      

      We should be more intelligent in such cases.

      Would it be worth the effort to find and fix them all?

      I believe it would be interesting with a few tickets for a few obvious
      leaks. However, to be honest, I am not sure when this can be fixed:
      memory leaks checking is not getting a lot of attention. :-(

      Den fre 28 juni 2019 kl 19:15 skrev Nick Ridgway
      rebnridgway@users.sourceforge.net:

      I recently found a false-negative bug in the checker for unsafeClassCanLeak that was caused by the fact that placement new was used to allocate the member that should have caused the warning. It could be that there are more checkers that look for uses of new that wouldn't match a placement new, do you know how likely it is that more checkers are affected by this? Would it be worth the effort to find and fix them all?


      Placement new support


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/cppcheck/discussion/development/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.