Re: [protobuf] Re: FAIL: Structured exception occurred [Access Violation].

190 views
Skip to first unread message
Message has been deleted
Message has been deleted

Adam Cozzette

unread,
May 17, 2023, 5:48:42 PM5/17/23
to Harsh Ranjan, Protocol Buffers
The code you have posted looks fine as far as I can tell, so if there is a memory leak then I think the problem is elsewhere. I suspect that the TelemetryProtobuf::EventName proto passed to PopulateEventName() is not getting destroyed. Or if you're using an arena, then the arena that proto was allocated on is not getting destroyed.

On Wed, May 17, 2023 at 1:18 PM Harsh Ranjan <harshra...@gmail.com> wrote:
It is cpp code. I initially thought the issue is NULL pointers but then I replaced all the fields with hardcoded constant values and I still got the same issue. 

On Wednesday, May 17, 2023 at 12:41:37 PM UTC-7 Harsh Ranjan wrote:
Hey Team,

I have been trying to add unit-test for my protobuf class. Attaching the full error as pdf.

[3 / 3] Leaked 72 bytes allocated at 000002E2A001AAC0
     at Mso::Memory::AllocateEx [liblet\debugheap\memoryapiimpl\memoryapi.cpp(19)]
     at Mso::Memory::Throw::AllocateEx [x64\debug\liblet_operatornew\x-none\x64\inc\core\memoryApi_throw.h(29)]
     at operator new [x64\debug\liblet_precomp\x-none\x64\inc\core\memoryNew_Throw.h(61)]
     at google::protobuf::Arena::CreateInternal<TelemetryProtobuf::EventNamespace> [x64\debug\telemetry_serializersink\x-none\x64\inc\google\protobuf\arena.h(527)]
     at google::protobuf::Arena::CreateMaybeMessage<TelemetryProtobuf::EventNamespace> [telemetry\serializersink\telemetryevent_v310.pb.cc(12052)]
     at google::protobuf::MessageLite::CreateMaybeMessage<TelemetryProtobuf::EventNamespace> [x64\debug\telemetry_serializersink\x-none\x64\inc\google\protobuf\message_lite.h(449)]

I am just populating the protobuf event.
void PopulateEventNameSpace(TelemetryProtobuf::EventNamespace& protobufEventNamespace, const Telemetry::TelemetryNamespace& telemetryNamespace) noexcept
{
protobufEventNamespace.set_fullnamelength(8);
protobufEventNamespace.set_nodenamecount(1010);
}

void PopulateEventName(TelemetryProtobuf::EventName& protobufEventName, const Telemetry::EventName& telemetryEventName) noexcept
{
protobufEventName.set_eventnodename("baz");
PopulateEventNameSpace(*protobufEventName.mutable_eventnamespace(), telemetryEventName.GetNamespace());
}

Anything I am missing here? I am using the protobuf version 3.10

Thanks,
Harsh

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/45432e0a-50e0-48de-8811-50024981d805n%40googlegroups.com.
Message has been deleted

Adam Cozzette

unread,
May 17, 2023, 6:32:52 PM5/17/23
to Harsh Ranjan, Protocol Buffers
It's hard to know the answer to those questions without knowing how protobufEventName was created. If it was allocated on the stack then it will be automatically destroyed once it goes out of scope, but if it was allocated on the heap then you may need to explicitly delete it. If it was allocated on an arena then you just have to make sure the arena gets destroyed eventually.

On Wed, May 17, 2023 at 3:01 PM Harsh Ranjan <harshra...@gmail.com> wrote:
Do we need to explicitly destroy them? I am calling  google::protobuf::ShutdownProtobufLibrary() at then end but this error pops up before this. Should I try to get rid of pointers and work with copy?
Message has been deleted
Message has been deleted
Message has been deleted

Harsh Ranjan

unread,
May 19, 2023, 5:03:41 AM5/19/23
to Protocol Buffers
I am again facing the same issue. Is there anything I can do related to Memory leak or even suppress them for testing purpose?

On Wednesday, May 17, 2023 at 11:50:08 PM UTC-7 Harsh Ranjan wrote:
Looks like other folks faced similar issues with debug mode.
https://github.com/protocolbuffers/protobuf/issues/6443

On Wednesday, May 17, 2023 at 11:25:26 PM UTC-7 Harsh Ranjan wrote:
The code is working fine in release mode but in debug mode it is throwing Structured exception. Anyway by which we can enable same library for both debug and release mode.

On Wednesday, May 17, 2023 at 3:37:22 PM UTC-7 Harsh Ranjan wrote:

Is there a way I can debug on my local machine where protobufEventName  is getting created? That is either stack/heap or arena?
Based on the error it looks to me it is getting created in arena.
 at google::protobuf::Arena::CreateInternal<TelemetryProtobuf::EventNamespace> [x64\debug\telemetry_serializersink\x-none\x64\inc\google\protobuf\arena.h(527)]
     at google::protobuf::Arena::CreateMaybeMessage<TelemetryProtobuf::EventNamespace> [telemetry\serializersink\telemetryevent_v310.pb.cc(12052)]

Adam Cozzette

unread,
May 22, 2023, 12:08:29 PM5/22/23
to Harsh Ranjan, Protocol Buffers
Can you narrow this down to a reproducible example?

If the parent message is created using something like Arena::CreateMessage<T>() then it's allocated on an arena, but otherwise it's allocated on the heap. I wouldn't necessarily trust the stack trace to tell you how it's allocated, because in some cases the generated code may exercise code in the Arena class even if arenas are not being used.

Reply all
Reply to author
Forward
0 new messages