[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Heap Corruption
From: |
Jot Dot |
Subject: |
Re: Heap Corruption |
Date: |
Thu, 10 Dec 2020 03:04:26 -0700 (MST) |
Adrian, Thanks for the suggestions.
> Heap corruption is always mean to debug…
I agree.
I don't have proper debug tools to debug this. Hopefully clang will help.
I've never used clang so I'll read up and use it.
> It could be that your heap was already corrupted way earlier, but only the
> “delete” notices that corruption which occurred for a totally independent
> reason.
I totally agree, but this time I pretty much just open a file and call the
parser. That's what is so confusing.
> In general, I would recommend to enable address sanitizer in your compile
> (“-fsanitize=address” flag in both gcc & clang; see
> https://clang.llvm.org/docs/AddressSanitizer.html) which should point you to
> the exact line of code which causes the corruption.
I'll definitely check this out. I see they have something for msvc which is
what I am using at the moment.
> Furthermore, I would in general recommend to always use
> `std::unique_ptr`/`std::make_unique` over “new” and “delete”.
Ok. I'm just starting to use STL more. Not familiar with the use benefits
of unique_ptr but I'll check it out.
> If you could post a self-contained repro that would me to follow your steps
> and
> maybe debug this in more depth.
I'll chop the source down a bit and see if I can get a minimal source file
with the same error. In the meantime, I'll check out clang as well.
If I can't sort this out, then I'll post a minimal set of source files.
I figure I should attempt to do the work as much as possible first.
I really appreciate the clang tip. Without something like that, I think
that I'd have an impossible time with this.
Well, it's 4 am here and I have to get up at 7 am so I think it will have
to wait a bit.
Thanks :)