Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot, Exalead

Members: 0
Guests: 17
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » AFKMud Support & Development » Liquid.c
Forum Rules | Mark all | Recent Posts

Liquid.c
< Newer Topic :: Older Topic > Errors and Segfaults

Pages:<< prev 1 next >>
Post is unread #1 Sep 26, 2004, 10:15 am
Go to the top of the page
Go to the bottom of the page

Cernos

GroupMembers
Posts7
JoinedSep 22, 2004

I was working with liquids and found that a few things were giving me segfaults. I did have change some things in do_setliquid( "list" ) and save_liquids(). Under save_liquids() it wouldn't save newly created liquids. I changed this for( i = 0; i < top_liquid; i++ ) to this for(i = 0; i <= top_liquid; i++) and it saved fine. I also changed for(i = 0; i < top_liquid; i++) to this for(i = 0; i type = -1; to this liq->type = 0; in do_setliquid( "create" ) because the -1 was fine when you created it. But if you type setliquid list vnum, with vnum being the vnum of the newly created liquid, without changing the liq->type to a valid type it will segfault. If these fixes have already been applied and I just have an old version please disregard.

I am however running into a problem when I try to do_setliquid( "delete" ). I am not sure how to get my system to produce a core when it segfaults, but I get one everytime I type setliquid delete vnum. Vnum of course is an actual vnum. When I log back in to the mud the liquid table is empty. No idea what I should do.
       
Post is unread #2 Sep 26, 2004, 10:48 pm
Go to the top of the page
Go to the bottom of the page

Cernos

GroupMembers
Posts7
JoinedSep 22, 2004

I edited the original post to add another change I did but forgot to put in the first one. Then I realized that if someone read the first one they probably wouldn't read it again not knowing there was a change.
       
Post is unread #3 Sep 26, 2004, 11:18 pm
Go to the top of the page
Go to the bottom of the page

Cernos

GroupMembers
Posts7
JoinedSep 22, 2004

This is the section of code that is causing the segfault.

else if( !str_cmp( arg, "delete" ) )
{
LIQ_TABLE *liq = NULL;
int i = atoi( argument );

send_to_char( "Insert crash here.
", ch );
if( NULLSTR( argument ) )
{
send_to_char( "Syntax: setliquid delete
", ch );
return;
}

if( ( liq = get_liq_vnum( i ) ) == NULL )
{
send_to_char( "No such vnum. Use 'setliquid list' to gain the vnums.
", ch );
return;
}

STRFREE( liq->name );
STRFREE( liq->color );
STRFREE( liq->shortdesc );

if( liq->vnum >= top_liquid )
{
int j;

for( j = 0; j != liq->vnum; j++ )
if( j > top_liquid )
top_liquid = j;
}

liquid_table[liq->vnum] = NULL;
liq_count--;
DISPOSE( liq );
send_to_char( "Done.
", ch );
save_liquids( );
return;
}

Thanks.
       
Post is unread #4 Sep 27, 2004, 11:33 am
Go to the top of the page
Go to the bottom of the page

Xorith
The Null Value
GroupAFKMud Team
Posts254
JoinedFeb 23, 2003

I am at work, so I can't check for myself...

A few things stick out:


if( NULLSTR( argument ) )
{
send_to_char( "Syntax: setliquid delete
", ch );
return;
}


Find and check the NULLSTR macro. Long shot, but it's not something I've seen. It could be Samson's implementation of the macro I came up with. I think he fixed it up actually.


if( ( liq = get_liq_vnum( i ) ) == NULL )
{
send_to_char( "No such vnum. Use 'setliquid list' to gain the vnums.
", ch );
return;
}


There could possibly be a bug in get_liq_vnum. You mentioned before that liq's with a negative vnum produced a segfault. Worth a look.


STRFREE( liq->name );
STRFREE( liq->color );
STRFREE( liq->shortdesc );


Be sure that these variables are being set with STRALLOC! In terms of memory, name and color should be STRALLOC/STRFREE, while shortdesc should probably be mudstrcpy/mudstrcat/str_dup and DISPOSE(), though the minimum wold be to just make sure they're all using STRALLOC if they're being STRFREE'd.

-- Xorith
       
Post is unread #5 Sep 27, 2004, 3:53 pm
Go to the top of the page
Go to the bottom of the page

Cernos

GroupMembers
Posts7
JoinedSep 22, 2004

I changed a few things in the code and now it does not segfault, but it doesn't delete the liquid vnum either. It sets the values to NULL and leaves behind a vnum of 0. SO I end up with multiple 0 vnums.

else if( !str_cmp( arg, "delete" ) )
{
LIQ_TABLE *liq = NULL;
int i = atoi( argument );

if( NULLSTR( argument ) )
{
send_to_char( "Syntax: setliquid delete
", ch );
return;
}

if( ( liq = get_liq( argument ) ) == NULL ) name );
STRFREE( liq->color );
STRFREE( liq->shortdesc );

if( liq->vnum >= top_liquid )
{
int j;

for( j = 0; j != liq->vnum; j++ )
if( j > top_liquid )
top_liquid = j;
}

/* liquid_table[liq->vnum] = NULL; */ vnum = NULL; <----added this but it only sets the vnum to NULL and 0 when saved
liq_count--;
DISPOSE( liq );
send_to_char( "Done.
", ch );
save_liquids( );
return;
}

Not exactly sure how to get it to delete it now. Any suggestions?
       
Post is unread #6 Sep 28, 2004, 9:41 am
Go to the top of the page
Go to the bottom of the page

Xorith
The Null Value
GroupAFKMud Team
Posts254
JoinedFeb 23, 2003

It's usually a bad idea to 'adjust' vnums when things are removed.

For instance:

liqA, vnum 10
liqB, vnum 11
liqC, vnum 12

If I remove liqB, liqC should not become vnum 12.

Why is this bad?

Lets say part of the code uses the vnum to refer to the liquid. If something points to vnum 11, and intended it to be liqB... if it adjusts the vnums when liqB is removed, then it'll point to liqC instead. The better idea is to simply pull the liq based on vnum, and if none, assume it's gone.
       
Post is unread #7 Sep 28, 2004, 4:39 pm
Go to the top of the page
Go to the bottom of the page

Cernos

GroupMembers
Posts7
JoinedSep 22, 2004

I am not trying to set the VNUM. I am just trying to change the code that already existed so it won't crash. The original code set it to NULL and that's what I did. What I did doesn't segfault, but it doesn't delete it either. It sets it to NULL and then when the save_liquid function executes it writes it to file as 0 vnum. I can't figure out how to get the thing to delete instead of just setting all the fields to NULL.
       
Post is unread #8 Oct 2, 2004, 12:39 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Lets just say that this bug is quite serious and has been fixed. See the bugfix list. Quite the glaring problem.
       
Pages:<< prev 1 next >>