realloc(): invalid next size

103 views
Skip to first unread message

William Ma

unread,
Dec 19, 2014, 5:39:45 AM12/19/14
to
I have tracked where the error mentioned at https://groups.google.com/forum/?hl=en#!topic/link-grammar/XnHPHh-j0Fs to the line where it occurs.  Right now, this happens when putting dictionary_create_default_lang() into an OpenCog module.  For example, suppose a new empty OpenCog module and put the following line into its init() method

dictionary_delete(dictionary_create_default_lang());

will produce the error.  The error seems to always happen when the affix dictionary (en/4.0.affix) is being processed, and it is produced on xrealloc() within affix_list_resize() method, called by affix_list_add() method, called by load_affix().  On the few runs I have tried, it is called when it tries to add "₳" of the LPUNC+ list but found ac->length == 64 and needs to be increased (I suspect it will be different on different machine or when running at different time).

This never happens when dictionary_create_default_lang() is called within its own program, so I am not sure whether the problem is within OpenCog or within LinkGrammar.

William

Linas Vepstas

unread,
Dec 19, 2014, 1:22:14 PM12/19/14
to link-grammar
I'm looking at this now, and its totally bizarre. --linas

On Fri, Dec 19, 2014 at 4:39 AM, William Ma <willia...@gmail.com> wrote:
I have tracked where the error mentioned at https://groups.google.com/forum/?hl=en#!topic/link-grammar/XnHPHh-j0Fs to the line where it occurs.  Right now, this happens when putting dictionary_create_default_lang() into an OpenCog module.  For example, suppose a new empty OpenCog module and put the following line into its init() method

dictionary_delete(dictionary_create_default_lang());

will produce the error.  The error seems to always happen when the affix dictionary (en/4.0.affix) is being processed, and it is produced on xrelloc() within affix_list_resize() method, called by affix_list_add() method, called by load_affix().  On the few runs I have tried, it is called when it tries to add "₳" of the LPUNC+ list but found ac->length == 64 and needs to be increased (I suspect it will be different on different machine or when running at different time).

This never happens when dictionary_create_default_lang() is called within its own program, so I am not sure whether the problem is within OpenCog or within LinkGrammar.

William

--
You received this message because you are subscribed to the Google Groups "link-grammar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to link-grammar...@googlegroups.com.
To post to this group, send email to link-g...@googlegroups.com.
Visit this group at http://groups.google.com/group/link-grammar.
For more options, visit https://groups.google.com/d/optout.

ami...@gmail.com

unread,
Dec 19, 2014, 1:28:21 PM12/19/14
to link-g...@googlegroups.com
I'm trying to fix that. Stay tuned.

Linas Vepstas

unread,
Dec 19, 2014, 1:31:33 PM12/19/14
to link-grammar
what I'm seeing is totally crazy behavior, as if realloc itself was broken, and/or if the gcc optimizer is using the old ac->string pointer. which is crazy.. -- linas

On Fri, Dec 19, 2014 at 12:28 PM, <ami...@gmail.com> wrote:
I'm trying to fix that. Stay tuned.

--

Linas Vepstas

unread,
Dec 19, 2014, 2:01:35 PM12/19/14
to link-grammar
Found it.  Apparently, /usr/lib/libbfd-2.24-system.so has a symbol called "xrealloc" in it, and opencog links to libbfd to perform pretty stack-trace printing. Due to dynamic linking order, the xrealloc in link-grammar gets resolved by the symbol in libbfd, instead of the one in liblink-grammar.  The libbfd version is expecting the new size as the second argument. But we pass the old size in that location. So the returned arrays are always too small, and memory corruption results.

The solution is to stop using xrealloc which no longer serves a purpose anyway.

I'll push  a fix for this shortly.

--linas

Linas Vepstas

unread,
Dec 19, 2014, 2:53:05 PM12/19/14
to link-grammar
William,

To get this fix, you'll need to work out of the current git directly. For that, you'll need to install all of autotools, automake, etc. and then run ./autogen.sh --no-configure and then run ../configure

A different work-around would be to rebuild opencog without libbfd in it (disaple 'pretty stack trace printing' in cmake)

--linas

William Ma

unread,
Dec 21, 2014, 9:53:36 PM12/21/14
to link-g...@googlegroups.com, linasv...@gmail.com
Thanks for the fix, Linas.

I tried building LG from the git repo, but it looks like the error mentioned on https://groups.google.com/forum/#!topic/link-grammar/-m4_itIocDQ is still there.

"../configure: line 17394: syntax error near unexpected token `2.0.0,'
../configure: line 17394: `AX_PKG_SWIG(2.0.0, SwigF=yes, SwigF=no)'

I will try to figure out how to work around that.

William

Linas Vepstas

unread,
Dec 21, 2014, 10:37:45 PM12/21/14
to William Ma, link-grammar
ahh, you need to install the autoconf archive  Its autoconf-archive on ubuntu

-linas
Reply all
Reply to author
Forward
0 new messages