Go Back   Angband Forums > Angband > Development

Thread Tools Display Modes
Old Today, 01:31   #51
DaJAngband Maintainer
will_asher's Avatar
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 1,005
Donated: $10
will_asher is on a distinguished road
How do I know if it's writing beyond the boundaries of an array?
and How do I know what the boundaries are?

When I first started making DaJAngband, I just discovered the txt files in the lib folder (the subfolder was called something other than gamedata at that point), and changed some things and added some new monsters. I posted about making changes in the txt files on here, and someone suggested I make my own variant. I said I can't do that I know only the barest basics of C, but they said something to the effect of Oh it isn't hard, you can probably figure a lot of things out by the comments. So I looked at the code, and the comments were so thorough in saying what the code was doing, that I could figure out how to customize a lot of stuff in the code. I'm a meddler, not a programmer, but I made my own variant before. I can do it again (with the help of the nice people here).
aka LibraryAdventurer

My old variant DaJAngband: (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)
will_asher is offline   Reply With Quote
Old Today, 05:21   #52
Join Date: Aug 2019
Posts: 136
backwardsEric is on a distinguished road
Originally Posted by will_asher View Post
How do I know if it's writing beyond the boundaries of an array?
and How do I know what the boundaries are?
There's tools to help detect them. I don't know what's best or readily available for your environment (Windows + Visual Studio). Electric Fence, , is one fairly generic one for C. Like many of those tools, it's likely best used in conjunction with a source debugger that will let you set breakpoints and query the call stack and contents of memory.

As for the second question, the boundaries are set when the memory allocation happened - with the size that was passed to the allocator.

Besides finding a tool to help detect the source of the memory corruption, manually reviewing your changes, while time-consuming, will likely help. Did the parts you added to the player structure involve dynamic allocation (likely if they are pointers)? If so, check that the size specified for allocation is the right one. Try to identify the lifetime of what was allocated - when is it allocated and when is it released. Are there attempts to access it after it is released (either for reading, writing, or to release it again)? If so, that would be a problem. If you didn't add anything that required dynamic allocation, you would want to check your changes to the savefile loading. Are the loads of the right size and not overflowing the destination memory?
backwardsEric is offline   Reply With Quote

Currently Active Users Viewing This Thread: 2 (0 members and 2 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
can we make identify more common ? Sky Vanilla 16 September 10, 2017 10:20
Make Artistry automatic bagori nd Sil 4 September 26, 2016 18:22
How many variant developers/maintainers have beaten their own variant? Delver Variants 12 June 5, 2009 09:08
Variant writing.. quickstart guide? Also, Hengband variant suggestions? dzhang Variants 34 April 1, 2009 00:45
Trying to make my own variant bpleshek Variants 8 September 15, 2008 20:42

All times are GMT +1. The time now is 05:53.

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