This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

MegaHal 2.7 and Eggdrop v1.6.20+bindmodecase

Discussion of Eggdrop's code and module programming in C.
Post Reply
k
kulpae
Voice
Posts: 3
Joined: Fri Nov 13, 2009 9:09 pm

MegaHal 2.7 and Eggdrop v1.6.20+bindmodecase

Post by kulpae »

Hello guys,
I just tried to run the latest eggdrop from the cvs repo and got weird memory errors from megahal module. But before (with Eggdrop 1.6.19+ctcpfix) everything worked, even megaHal.

this is what I get, when running eggdrop:

Code: Select all

[02:15] *** ATTEMPTING TO FREE NON-MALLOC'D PTR: megahal:megahal.c (1094)
[02:15] *** ATTEMPTING TO FREE NON-MALLOC'D PTR: megahal:megahal.c (1094)
(absolutely the same message several times)
[02:15] *** ATTEMPTING TO FREE NON-MALLOC'D PTR: megahal:megahal.c (1094)
[02:15] *** MEMORY TABLE FULL: megahal:megahal.c (1275)
more about my sys:
ubuntu server 8.10 x86_64
MegaHal from here

what has changed since Eggdrop 1.6.19+ctcpfix?
The first error is really weird, since at line 1094 of megaHal.c nfree is called on a non-NULL ptr...
As I said before, the same megaHal version worked nicely with 1.6.19 (okay, I had to remove the brain in order to start eggdrop...)

hopefully someone can help me,
bb, kulpae

edit: I need the cvs revision because of the "bind out" feature...
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

It's not that it's trying to nfree a null-pointer, but a memory address that was not allocated using nmalloc() (memory-tracking version of malloc()).

There's probably no major change since the 1.6.19 eggie you are experiencing, but that you have actually compiled your eggie with memory debugging enabled. It's possible they've broken the nmalloc/nfree algorithms, I suppose, but I'd have to check recent changelogs to see if they've touched that (or the global export table).
You'd find this code in src/mem.c if you'd like to have a look yourself.
NML_375
k
kulpae
Voice
Posts: 3
Joined: Fri Nov 13, 2009 9:09 pm

Post by kulpae »

Yeah, thank you!
I can start eggdrop with megahal now (but have to remove the brain anyways, trying to fix that now...).

The solution was to increase the MEMTBLSIZE constant in src/mem.c from 25000 to 100000.

:D
I don't know how elegant this solution is, but it works ;)
Now I'm looking, how to start megahal with an existing brain (without removing it every time)

bb, kulpae
k
kulpae
Voice
Posts: 3
Joined: Fri Nov 13, 2009 9:09 pm

Post by kulpae »

Okay, had to fix some bugs in megahal.

the solution for this warnings:

Code: Select all

[02:15] *** ATTEMPTING TO FREE NON-MALLOC'D PTR: megahal:megahal.c (1094) 
is to replace all realloc calls in megahal.c with nrealloc.

And on my system (64bit) there were also a compiler warning, that I ignored first (something like: read size parameter is bigger than buffer length).
I checked it, and found out that int has the size of 4 on my machine, but BYTE4 has the size of 8!
so I went to megahal.h and changed

Code: Select all

#define BYTE4 unsigned long
to

Code: Select all

#define BYTE4 unsigned int
then configured with --enable-tcl-threads,
make iconfig, make && make install. done ;)

Now I can restart the bot, without this annoying Buffer Overflow Errors.

And I've increased the MEMTBLSIZE constant again to 200000, as the megahal brain grows...

thanks for showing me the way...

bb, kulpae
Post Reply