len_needed = ((buf->maxlen + to_replace*(b_len-a_len))*5)/4 + 20;
if(to_replace * (b_len - a_len) + buf->len > buf->maxlen)
len_needed = ((buf->maxlen + to_replace*(b_len-a_len))*5)/4 + 20;
}
if(to_replace * (b_len - a_len) + buf->len >= buf->maxlen)
len_needed = ((buf->maxlen + to_replace*(b_len-a_len))*5)/4 + 20;
}
int len_needed = buf->maxlen;
int len_needed = buf->maxlen + 1;
However, today I ran into the same problem trying to train a new builder for the mud, and she had nothing at all in there which was related to the scripts. I did a lot of wrangling with GDB, until I was finally able to track down the problem to the MUD trying to escape \r in the string.
Specific GDB information:
Run till exit from #0 bufferReplace (buf=0x82a4ba8, a=0x80a1db7 "\r", b=0x80a26ae "\\r", all=1) at buffer.c:145
*** glibc detected *** /usr/games/elvenblade/src/NakedMud: double free or corruption (!prev): 0x0829f5c0 ***
======= Backtrace: =========
/lib/libc.so.6[0x75b0d5]
/lib/libc.so.6(cfree+0x96)[0x75d126]
/usr/games/elvenblade/src/NakedMud[0x806b026]
/usr/games/elvenblade/src/NakedMud[0x806b1fa]
/usr/games/elvenblade/src/NakedMud[0x8072cd5]
/usr/games/elvenblade/src/NakedMud[0x8074f91]
/usr/games/elvenblade/src/NakedMud[0x8071399]
/usr/games/elvenblade/src/NakedMud[0x8062eb2]
/usr/games/elvenblade/src/NakedMud[0x80582bd]
/usr/games/elvenblade/src/NakedMud[0x805883d]
/lib/libc.so.6(__libc_start_main+0xe5)[0x7016d5]
/usr/games/elvenblade/src/NakedMud[0x804a2e1]
======= Memory map: ========
00101000-00238000 r-xp 00000000 08:05 47317847 /lib/libcrypto.so.0.9.8g
00238000-0024c000 rwxp 00136000 08:05 47317847 /lib/libcrypto.so.0.9.8g
0024c000-0024f000 rwxp 0024c000 00:00 0
00521000-00646000 r-xp 00000000 08:05 70868 /usr/lib/libpython2.5.so.1.0
00646000-0066c000 rwxp 00124000 08:05 70868 /usr/lib/libpython2.5.so.1.0
0066c000-00672000 rwxp 0066c000 00:00 0
00685000-00692000 r-xp 00000000 08:05 47316995 /lib/libgcc_s-4.3.2-20081105.so.1
00692000-00693000 rwxp 0000c000 08:05 47316995 /lib/libgcc_s-4.3.2-20081105.so.1
006c7000-006e7000 r-xp 00000000 08:05 47317043 /lib/ld-2.9.so
006e7000-006e8000 r-xp 0001f000 08:05 47317043 /lib/ld-2.9.so
006e8000-006e9000 rwxp 00020000 08:05 47317043 /lib/ld-2.9.so
006eb000-0085d000 r-xp 00000000 08:05 47317078 /lib/libc-2.9.so
0085d000-0085f000 r-xp 00172000 08:05 47317078 /lib/libc-2.9.so
0085f000-00860000 rwxp 00174000 08:05 47317078 /lib/libc-2.9.so
00860000-00863000 rwxp 00860000 00:00 0
00865000-00868000 r-xp 00000000 08:05 47317835 /lib/libdl-2.9.so
00868000-00869000 r-xp 00002000 08:05 47317835 /lib/libdl-2.9.so
00869000-0086a000 rwxp 00003000 08:05 47317835 /lib/libdl-2.9.so
0086c000-00882000 r-xp 00000000 08:05 47317165 /lib/libpthread-2.9.so
00882000-00883000 r-xp 00015000 08:05 47317165 /lib/libpthread-2.9.so
00883000-00884000 rwxp 00016000 08:05 47317165 /lib/libpthread-2.9.so
00884000-00886000 rwxp 00884000 00:00 0
00888000-008af000 r-xp 00000000 08:05 47317834 /lib/libm-2.9.so
008af000-008b0000 r-xp 00026000 08:05 47317834 /lib/libm-2.9.so
008b0000-008b1000 rwxp 00027000 08:05 47317834 /lib/libm-2.9.so
008b3000-008cd000 r-xp 00000000 08:05 47317836 /lib/libselinux.so.1
008cd000-008ce000 r-xp 00019000 08:05 47317836 /lib/libselinux.so.1
008ce000-008cf000 rwxp 0001a000 08:05 47317836 /lib/libselinux.so.1
008d1000-008e4000 r-xp 00000000 08:05 47317833 /lib/libz.so.1.2.3
008e4000-008e5000 rwxp 00012000 08:05 47317833 /lib/libz.so.1.2.3
008e7000-008e9000 r-xp 00000000 08:05 47317039 /lib/libutil-2.9.so
008e9000-008ea000 r-xp 00001000 08:05 47317039 /lib/libutil-2.9.so
008ea000-008eb000 rwxp 00002000 08:05 47317039 /lib/libutil-2.9.so
0090a000-00914000 r-xp 00000000 08:05 47318493 /lib/libcrypt-2.9.so
00914000-00915000 r-xp 00009000 08:05 47318493 /lib/libcrypt-2.9.so
00915000-00916000 rwxp 0000a000 08:05 47318493 /lib/libcrypt-2.9.so
00916000-0093d000 rwxp 00916000 00:00 0
0093f000-00941000 r-xp 00000000 08:05 47317846 /lib/libcom_err.so.2.1
00941000-00942000 rwxp 00001000 08:05 47317846 /lib/libcom_err.so.2.1
00969000-0098d000 r-xp 00000000 08:05 76464 /usr/lib/libk5crypto.so.3.1
0098d000-0098e000 rwxp 00024000 08:05 76464 /usr/lib/libk5crypto.so.3.1
00990000-00999000 r-xp 00000000 08:05 76081 /usr/lib/libkrb5support.so.0.1
00999000-0099a000 rwxp 00008000 08:05 76081 /usr/lib/libkrb5support.so.0.1
0099c000-0099e000 r-xp 00000000 08:05 47317845 /lib/libkeyutils-1.2.so
0099e000-0099f000 rwxp 00001000 08:05 47317845 /lib/libkeyutils-1.2.so
009a1000-009ce000 r-xp 00000000 08:05 76467 /usr/lib/libgssapi_krb5.so.2.2
009ce000-009d0000 rwxp 0002d000 08:05 76467 /usr/lib/libgssapi_krb5.so.2.2
009d2000-00a19000 r-xp 00000000 08:05 47317848 /lib/libssl.so.0.9.8g
00a19000-00a1d000 rwxp 00046000 08:05 47317848 /lib/libssl.s
Program received signal SIGABRT, Aborted.
0x007166d6 in raise () from /lib/libc.so.6
So naturally I went through and tried to figure out what's going on here, the first spot I looked of course was in that actual function in ./src/buffer.c, around line 172:
I do not, however, see anything that is immediately wrong with that, so after a few hours of spinning my wheels pointlessly, I suppose I'll paint myself a big target on myself (considering earlier this morning in other topics) and see if anyone sees issues with that which I'm missing.
Maya/Rudha
[edit] For the sake of completeness and verbosity, the description content was:
The existing room prototype resource content: