[cfe-users] check for double delete

David Blaikie dblaikie at gmail.com
Mon Aug 26 07:20:35 PDT 2013


On Aug 26, 2013 2:45 AM, "Bernd Schubert" <bernd.schubert at itwm.fraunhofer.de>
wrote:
>
> Thanks Anna,
>
> and sorry, it was just some pseudo code I quickly wrote down. Hmm,
> indeed it does report it, but it didn't for the actual code I was using.
> Ah, the actual code has foo() in a different file. Is it possible to use
> the analyzer with link time optimization?

Technical point: the static analyzer acts on ASTs, so lto is too late as it
acts on llvm ir.

Practical point: no, theatres no cross-TU support in the static analyzer at
the moment

>
> Thanks,
> Bernd
>
> On 08/02/2013 07:04 PM, Anna Zaks wrote:
> > Bernd,
> >
> > The latest analyzer should warn about double frees.
> >
> > The code you provided does not compile, but the analyzer warns on this
> > fixed code snippet:
> > class my_object_t {};
> > void foo(my_object_t *obj) {
> > delete obj;
> > }
> > int foo2() {
> > my_object_t *obj = new my_object_t;
> > if (!obj)
> > return -1;
> > foo(obj);
> > delete obj;
> > }
> >
> > */Users/zaks/tmp/ex.cpp:10:2: **warning: **Attempt to free released
memory*
> >         delete obj;
> >
> > Cheers,
> > Anna.
> > On Aug 2, 2013, at 5:09 AM, Bernd Schubert
> > <bernd.schubert at itwm.fraunhofer.de
> > <mailto:bernd.schubert at itwm.fraunhofer.de>> wrote:
> >
> >> Hi all,
> >>
> >> is there some way to instruct the static analyzer to check for double
> >> deleted objects?
> >>
> >>
> >> void foo(my_object_t obj)
> >> {
> >> delete obj;
> >> }
> >>
> >> main()
> >> {
> >> my_object_t *obj = new my_object_t;
> >>
> >> if (!obj)
> >> return -1;
> >>
> >> foo(obj);
> >>
> >> delete obj;
> >> }
> >>
> >>
> >> I just found something like that in my code and the static analyzer
> >> hadn't detected it.
> >>
> >>
> >> Thanks,
> >> Bernd
> >>
> >> _______________________________________________
> >> cfe-users mailing list
> >> cfe-users at cs.uiuc.edu <mailto:cfe-users at cs.uiuc.edu>
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
> >
>
> _______________________________________________
> cfe-users mailing list
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20130826/eebb437b/attachment.html>


More information about the cfe-users mailing list