lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Zé Pedro wrote:
> I'm sorry to insist in this question but I'm really stuck in here. I
> have 27 types of data that I want to export to lua from C++. Everything
> was working until I defined my 18th data type. When I try to execute a
> script my program crashes with core dump while trying to reallocate
> memory. Here is the error:
> 
> *** glibc detected *** realloc(): invalid next size: 0xb4a0fcd8 ***

This means that something, somewhere has corrupted memory and that glibc has
noticed that its list of free memory blocks makes no sense.

> If I comment one data type definition the program doesn't crashes. Any
> idea on how to solve this problem?

Unfortunately the problem with this kind of error is that just because your
program doesn't crash it doesn't mean it's working. Unless you find and fix
the root cause of the problem, it probably just means you're corrupting
something that's not currently in use (but will be soon).

Luckily, there are tools that help: it looks like you're on a Unix system, so
you should get a copy of valgrind. This is an extremely sensitive memory
tester (which actually works by interpreting your machine code, but that's too
scary to think about). You run your program under valgrind, and it will do
extensive checks to make sure that you're not accessing memory you shouldn't
be. This will normally pinpoint the exact place where your program starts to
go wrong.

(Alternatively, develop on OpenBSD --- it does this kind of validation
automatically, all the time!)

-- 
┌── dg@cowlark.com ─── http://www.cowlark.com ───────────────────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out how to
│ use my telephone." --- Bjarne Stroustrup

Attachment: signature.asc
Description: OpenPGP digital signature