Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old March 29, 2016, 13:47   #11
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
Quote:
Originally Posted by Therem Harth View Post
Edit: oh N/M, I see what you're saying. Though I'm surprised it doesn't show the full stack trace.
It probably would if you build the libraries with debug info. Release libraries are stripped bare. But yeah, I don't get why there is no call trace - maybe the memory was allocated by a worker thread, in which case all bets are off
calris is offline   Reply With Quote
Old March 29, 2016, 14:18   #12
calris
Adept
 
Join Date: Mar 2016
Posts: 194
calris is on a distinguished road
This one has me stumped:

Code:
Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7f9da5f6796a in malloc (/lib64/libasan.so.2+0x9896a)
    #1 0x62c3f9 in mem_alloc /home/gruss/Angband_devel/angband/src/z-virt.c:41
    #2 0x62c482 in mem_zalloc /home/gruss/Angband_devel/angband/src/z-virt.c:54
    #3 0x61d5e9 in dice_new /home/gruss/Angband_devel/angband/src/z-dice.c:197
    #4 0x48c636 in parse_class_dice /home/gruss/Angband_devel/angband/src/init.c:3573
    #5 0x52c087 in parser_parse /home/gruss/Angband_devel/angband/src/parser.c:335
    #6 0x52d866 in parse_file /home/gruss/Angband_devel/angband/src/parser.c:671
    #7 0x48ce17 in run_parse_class /home/gruss/Angband_devel/angband/src/init.c:3682
    #8 0x52d5f1 in run_parser /home/gruss/Angband_devel/angband/src/parser.c:629
    #9 0x48fda8 in init_arrays /home/gruss/Angband_devel/angband/src/init.c:4412
    #10 0x48ff36 in init_angband /home/gruss/Angband_devel/angband/src/init.c:4488
    #11 0x62dfc4 in main /home/gruss/Angband_devel/angband/src/main.c:553
    #12 0x7f9da456157f in __libc_start_main (/lib64/libc.so.6+0x2057f)
The dice allocated in parse_class_dice() appear, to me, to be attached to a spell effect of a spell in a spell book.

But this is all cleaned up in cleanup_class(). For every spell in every book, a call to free_effect(spell->effect) is made which frees the dice:

Code:
void free_effect(struct effect *source)
{
	struct effect *e = source, *e_next;
	while (e) {
		e_next = e->next;
		dice_free(e->dice);   <--- HERE
		mem_free(e);
		e = e_next;
	}
}
So why are we left with one solitary dice in memory?

I even went as far as logging every dice create and free, and sure enough, there is an odd number of rows - So there is a mismatch between creation and freeing

EDIT: Found it - Bug in class.txt:1979

Code:
spell:Resist Heat and Cold:15:13:45:4
effect:TIMED_INC:OPP_COLD
dice:10+d10
effect:TIMED_INC:OPP_FIRE
dice:10+d10
desc:Gives you temporary resistance to cold and fire, for 10+1d10 turns each.
dice:10+d10  <-- HERE
desc:Gives you temporary resistance to cold and fire, for 10+1d10 turns each.
EDIT: Which raises the question - How much sanity checking do we need for these files? It's pretty easy to put in a check for this instance (it's how I found it after all), but do we need to trap every case of possible double mem_alloc() due to an error in the data files? And what do we do if we find one - mem_free() the fist and overwrite with the new one? That can get messy if you accidentally duplicate an effect:, or spell:, or book: line as it would requiring rewinding at various levels.

I'm thinking to catch the duplicates (easy to do) and spit out an plog message and just ignore the duplicate

Last edited by calris; March 29, 2016 at 15:01.
calris is offline   Reply With Quote
Old March 29, 2016, 19:13   #13
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by calris View Post
EDIT: Which raises the question - How much sanity checking do we need for these files? It's pretty easy to put in a check for this instance (it's how I found it after all), but do we need to trap every case of possible double mem_alloc() due to an error in the data files? And what do we do if we find one - mem_free() the fist and overwrite with the new one? That can get messy if you accidentally duplicate an effect:, or spell:, or book: line as it would requiring rewinding at various levels.

I'm thinking to catch the duplicates (easy to do) and spit out an plog message and just ignore the duplicate
I think the correct behaviour on input errors at initialisation is to report an error and exit. Seems like a whole bunch of parsing logic could do with this, though I suppose it's not as important if there's no memory allocation happening.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old March 29, 2016, 19:23   #14
redlumf
Scout
 
Join Date: Aug 2015
Posts: 25
redlumf is on a distinguished road
Amiga OS has no resource tracking, which means if you leak memory then the memory is "lost" for the OS. Of course, C's malloc does some housekeeeping and autoclean up at exit. But if you hit the OS directly bypassing it...

Code:
3.Work:t/asm/ang> avail
Type  Available    In-Use   Maximum   Largest
chip    2006040     87016   2093056   2005176
fast  150653816    341128 150994944 134217696
total 152659856    428144 153088000 134217696
3.Work:t/asm/ang> angband >ser:
3.Work:t/asm/ang> avail         
Type  Available    In-Use   Maximum   Largest
chip    2006040     87016   2093056   2005176
fast  150653736    341208 150994944 134217696
total 152659776    428224 153088000 134217696
3.Work:t/asm/ang> eval 428224-428144
80
There! 80 bytes lost by starting in town and exit.
redlumf is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DUNGEON_HGT considered harmful seebs Development 2 May 17, 2013 23:35
what is considered a clean win? pamperedpeterson Vanilla 56 January 29, 2008 09:02


All times are GMT +1. The time now is 07:21.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.