<div dir="ltr">Thanks, Josh. But I'll still ask if you use any debugging tool when get stuck.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 2:47 AM, Joshua Root <span dir="ltr"><<a href="mailto:jmr@macports.org" target="_blank">jmr@macports.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2017-7-11 06:14 , Umesh Singla wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi<br>
<br>
I'm running into an issue while storing port variants into another table in the registry database. The output is different every time and breaks at different places (though I can expect such erroneous behavior in case of such errors), many times finishing successfully.<br>
<br>
The common error which it gives me is:<br>
<br>
----<br>
tclsh8.5(25738,0x7fff9815d3c0) malloc: *** error for object 0x7f8e005023b8: incorrect checksum for freed object - object was probably modified after being freed.<br>
<br>
*** set a breakpoint in malloc_error_break to debug<br>
<br>
----<br>
<br>
I tried debugging a lot for over a day but not able to find anything.<br>
<br>
Sometimes, it gives me a Segmentation fault or Abort error: 6, all of them indicating an issue with memory management.<br>
<br>
If someone can try replicating the error, it'd be great. The repo is here [1]. The issue seems to be around here [2] in this function. After `make`, `sudo make install`, all you have to run is `<install-directory>/bin/port snapshot`.<br>
<br>
I am only using vim for development and unable to add any breakpoints and use GDB since it walks through Tcl.<br>
<br>
<br>
[1]: <a href="https://github.com/umeshksingla/macports-base/tree/gsoc17-migrate" rel="noreferrer" target="_blank">https://github.com/umeshksingl<wbr>a/macports-base/tree/gsoc17-<wbr>migrate</a><br>
<br>
[2]: <a href="https://github.com/umeshksingla/macports-base/blob/gsoc17-migrate/src/cregistry/entry.c#L1422" rel="noreferrer" target="_blank">https://github.com/umeshksingl<wbr>a/macports-base/blob/gsoc17-<wbr>migrate/src/cregistry/entry.c#<wbr>L1422</a><br>
</blockquote>
<br></span>
all_variants = (variant*) malloc(sizeof(variant));<br>
<br>
You are only allocating enough memory for one variant struct here, but then go on to treat it as an array. Also there's no error checking.<br>
<br>
- Josh<br>
</blockquote></div><br></div>