memory issue while writing to registrydb

Umesh Singla umeshksingla at macports.org
Mon Jul 10 23:55:07 UTC 2017


Thanks, Josh. But I'll still ask if you use any debugging tool when get
stuck.

On Tue, Jul 11, 2017 at 2:47 AM, Joshua Root <jmr at macports.org> wrote:

> On 2017-7-11 06:14 , Umesh Singla wrote:
>
>> Hi
>>
>> 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.
>>
>> The common error which it gives me is:
>>
>> ----
>> tclsh8.5(25738,0x7fff9815d3c0) malloc: *** error for object
>> 0x7f8e005023b8: incorrect checksum for freed object - object was probably
>> modified after being freed.
>>
>> *** set a breakpoint in malloc_error_break to debug
>>
>> ----
>>
>> I tried debugging a lot for over a day but not able to find anything.
>>
>> Sometimes, it gives me a Segmentation fault or Abort error: 6, all of
>> them indicating an issue with memory management.
>>
>> 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`.
>>
>> I am only using vim for development and unable to add any breakpoints and
>> use GDB since it walks through Tcl.
>>
>>
>> [1]: https://github.com/umeshksingla/macports-base/tree/gsoc17-migrate
>>
>> [2]: https://github.com/umeshksingla/macports-base/blob/gsoc17-
>> migrate/src/cregistry/entry.c#L1422
>>
>
> all_variants = (variant*) malloc(sizeof(variant));
>
> 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.
>
> - Josh
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-dev/attachments/20170711/f92a5831/attachment.html>


More information about the macports-dev mailing list