Closed GoogleCodeExporter closed 8 years ago
It seems that this is due to throwing an std::runtime_error. For example, see
http://stackoverflow.com/questions/4161401/leak-in-exception-code-c
In particular, if you run:
{{{
#include <stdexcept>
#include <iostream>
int main ()
{
try {
throw std::runtime_error("What");
} catch(const std::exception& e) {
std::cout << "exception: " << e.what () << "\n";
}
}
}}}
This will give exactly the same leak of
{{{
at 0xB823: malloc (vg_replace_malloc.c:266)
0x620CF: __cxa_get_globals (in /usr/lib/libstdc++.6.0.9.dylib)
by 0x61DCD: __cxa_allocate_exception (in /usr/lib/libstdc++.6.0.9.dylib)
}}}
(e.g.)
Notice, however, that this leak will only appear once, even if you throw many
exceptions (and catch them all).
So it appears that as long as we use `std::runtime_error` as the base class for
`YAML::Exception`, valgrind will find this leak.
Sorry :(
Original comment by jbe...@gmail.com
on 23 Jan 2012 at 6:08
I agree, one-time memory leak is not a big issue. However "blocks definitely
lost" and "invalid read" are completely different matters. The first one is
frequently a false positive while the second one is almost always an error.
Also you said, that it depends on exception but really it does not. I tried to
shorten input but after that valgrind errors disappeared while exception is
still thrown.
For me it is pretty clear, that you use delete node of deque, or maybe .front
() on empty dequeue or a pointer to deleted node.
Anyway i didn't mean bothering you, just hoped it would be an easy fix. And
also thanks for great library, i like it and it is very handy (i really dont
plan to parse malformed data all the time)
Original comment by svirshch...@gmail.com
on 23 Jan 2012 at 7:50
btw i dont see any leak, i see "invalid read of size 8". One-time leak when
throwing is probably a linux feature, while i run test on FreeBSD.
Original comment by svirshch...@gmail.com
on 23 Jan 2012 at 8:24
I see, I'm sorry, you're right. I didn't read it carefully enough, and I got
bogged down in hunting for that leak, not the invalid read. I'll check this out
tomorrow.
Thanks!
Original comment by jbe...@gmail.com
on 23 Jan 2012 at 8:49
Fixed, r0316abdc76a8.
Finally! :)
Original comment by jbe...@gmail.com
on 15 May 2012 at 4:10
Original issue reported on code.google.com by
svirshch...@gmail.com
on 23 Jan 2012 at 4:47Attachments: