memory issue while writing to registrydb

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

memory issue while writing to registrydb

Umesh Singla-2
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


Thanks

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: memory issue while writing to registrydb

Joshua Root-8
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: memory issue while writing to registrydb

Umesh Singla-2
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 <[hidden email]> 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

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: memory issue while writing to registrydb

Joshua Root-8
On 2017-7-11 09:55 , Umesh Singla wrote:
> Thanks, Josh. But I'll still ask if you use any debugging tool when get
> stuck.

In a case like this I would use libgmalloc. See its man page for details.

- Josh
Loading...