Here we go.
On 2009/5/15 18:56, Kenton Varda wrote:
> Ugh, I missed that one because I was doing my testing on Linux and
> that is in Windows-only code.
>
> Ideally I'd prefer if each GoogleOnce object registered a shutdown
> function for itself. But I suppose that could create a deadlock
> because the shutdown function registry is once-initialized. So, sure,
> use destructors. Do you want to send me a patch since you're set up
> to test it?
>
> On Fri, May 15, 2009 at 5:41 PM, Oleg Smolsky <[email protected]
> <mailto:[email protected]>> wrote:
>
> ...sent the message too quickly.
>
> So, the fix is trivial, yet it comes down to the same very
> discussion as the original issue. In this case it's cleaning up
> after the cleaners :) It's a global pointer that is initialized
> when global constructors (a.k.a. static initializers) run. The
> pointer to the heap block is never lost, but it is never
> deallocated either. The fix is trivial - all that is needed is the
> destructor. This, of course, assumes that the main thread would
> exit only after all additional workers are dead.
>
> Oleg.
>
>
> On 2009/5/15 17:28, Oleg Smolsky wrote:
>
> Actually, I got lucky - the culprit was not in headers. It's
> this line in once.cc:
>
> if (internal_ == NULL) internal_ = new GoogleOnceInternal;
>
> The log is as follows:
>
> Detected memory leaks!
> Dumping objects ->
> ..\src\google\protobuf\stubs\once.cc(65) : {1438} client block
> at 0x00B92620, subtype 0, 24 bytes long.
> Data: <h - > 68 A6 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {1437} client block
> at 0x00B925C8, subtype 0, 24 bytes long.
> Data: <0 - > 30 A6 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {946} client block
> at 0x00246AB0, subtype 0, 24 bytes long.
> Data: < - > A0 A1 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {945} client block
> at 0x00249CD0, subtype 0, 24 bytes long.
> Data: <h - > 68 A1 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {934} client block
> at 0x00249840, subtype 0, 24 bytes long.
> Data: <0 - > 30 A1 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {812} client block
> at 0x002469B0, subtype 0, 24 bytes long.
> Data: <x - > 78 9D 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(73) : {685} client block
> at 0x00B91FB0, subtype 0, 24 bytes long.
> Data: < - > D0 9C 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(73) : {667} client block
> at 0x00B91608, subtype 0, 24 bytes long.
> Data: <` - > 60 9C 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {666} client block
> at 0x00B915B0, subtype 0, 24 bytes long.
> Data: <( - > 28 9C 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {663} client block
> at 0x00B913D8, subtype 0, 24 bytes long.
> Data: <Pu- > 50 75 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {148} client block
> at 0x00245820, subtype 0, 24 bytes long.
> Data: <pt- > 70 74 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {147} client block
> at 0x002457C8, subtype 0, 24 bytes long.
> Data: <8t- > 38 74 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {136} client block
> at 0x00245290, subtype 0, 24 bytes long.
> Data: < t- > 00 74 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> ..\src\google\protobuf\stubs\once.cc(65) : {135} client block
> at 0x00245238, subtype 0, 24 bytes long.
> Data: < s- > C8 73 2D 00 FF FF FF FF 00 00 00 00 00 00 00 00
> Object dump complete.
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en
-~----------~----~----~----~------~----~------~--~---
diff -aru protobuf-2.1.0/src/google/protobuf/stubs/once.cc protobuf-2.1.0 -
Copy/src/google/protobuf/stubs/once.cc
--- protobuf-2.1.0/src/google/protobuf/stubs/once.cc 2009-05-13
13:36:36.000000000 -0700
+++ protobuf-2.1.0 - Copy/src/google/protobuf/stubs/once.cc 2009-05-15
19:18:09.405418300 -0700
@@ -56,6 +56,12 @@
CRITICAL_SECTION critical_section;
};
+GoogleOnceType::~GoogleOnceType()
+{
+ delete internal_;
+ internal_ = NULL;
+}
+
GoogleOnceType::GoogleOnceType() {
// internal_ may be non-NULL if Init() was already called.
if (internal_ == NULL) internal_ = new GoogleOnceInternal;
diff -aru protobuf-2.1.0/src/google/protobuf/stubs/once.h protobuf-2.1.0 -
Copy/src/google/protobuf/stubs/once.h
--- protobuf-2.1.0/src/google/protobuf/stubs/once.h 2009-05-13
13:36:36.000000000 -0700
+++ protobuf-2.1.0 - Copy/src/google/protobuf/stubs/once.h 2009-05-15
19:18:13.938418300 -0700
@@ -87,6 +87,7 @@
struct LIBPROTOBUF_EXPORT GoogleOnceType {
GoogleOnceType();
+ ~GoogleOnceType();
void Init(void (*init_func)());
volatile bool initialized_;
Only in protobuf-2.1.0/vsprojects: Release
Only in protobuf-2.1.0/vsprojects: _UpgradeReport_Files