CleverRaven / CleverRaven/Cataclysm-DDA
tinymap is anything but tiny
- Dominant language
- C++
- Stars
- 13.2k
- Forks
- 4.6k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 205
Description
According to my Visual Studio 2013 debug build of current master CDDA: sizeof(tinymap) == 332108.
This is an issue because tinymap is almost exclusively used on the stack. I've been running into stack overflow issues especially with the debug builds as I started to learn the source code. There are a couple of places (map::loadn) where these are used and occupy stack space and even worse recursively. And at least one place where 2 temps are used. I dont recall default stacksize for Windows but seems like 1 MB is about right which means you can allocate about 3 before you blow the stack. Something of this size unfortunately should be allocated on the heap.
I suggest using auto_ptr or unique_ptr or something to hold the maps, you can then use references so that all code does not have to be substantially rewritten to use pointer references.
Example:
std::auto_ptr tm(new tinymap());
tinymap &tmp_map = *tm;
##
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4019538-tinymap-is-anything-but-tiny?utm_campaign=plugin&utm_content=tracker%2F146201&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F146201&utm_medium=issues&utm_source=github).
Contributor guide
Research direction
Start by locating tinymap and its uses, especially map::loadn, and inspect where instances are created on the stack. Confirm the affected paths and ensure large temporary maps no longer risk stack overflow while preserving existing map behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100