Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Risk of deyncs due to std::set being sorted by pointer #2348

Closed
DorpsGek opened this issue Oct 13, 2008 · 2 comments
Closed

Risk of deyncs due to std::set being sorted by pointer #2348

DorpsGek opened this issue Oct 13, 2008 · 2 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

PhilSophus opened the ticket and wrote:

When discussing about MoveGoodsToStation in http://www.tt-forums.net/viewtopic.php?f=29&t=39800 I noticed that it uses a std::set<Station*>, i.e. a data structure sorted by the pointer address.

Although I'm still convinced that this is no problem as the pool system is organized now (pointers to pool items of the same pool are essentially pointers into the same array, making their comparison well defined IIRC) it may silently fail and cause dedyncs when this will be changed.

The attached patch provides the comparator template PoolItemIndexLess and uses it for the StationSet.

You might also have a look at the following places, which also use sets of pointers or pointer as map keys:

src/newgrf_storage.cpp:10:static std::set<BaseStorageArray*> _changed_storage_arrays;
src/newgrf_storage.cpp:20: for (std::set<BaseStorageArray*>::iterator it = _changed_storage_arrays.begin(); it != _changed_storage_arrays.end(); it++) {
src/driver.h:49: typedef std::map<const char *, DriverFactoryBase *, StringCompare> Drivers;
src/newgrf.cpp:260:typedef std::map<StringID *, uint32> StringIDToGRFIDMapping;
rc/town_cmd.cpp:2469:std::map<const Town *, int> _town_test_ratings;
src/town_cmd.cpp:2489: std::map<const Town *, int>::iterator it = _town_test_ratings.find(t);

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/2348
@DorpsGek
Copy link
Member Author

Rubidium wrote:

The others don't have different game characteristics when they are executed in a different order.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2348#comment4865

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r14463.


This comment was imported from FlySpray: https://bugs.openttd.org/task/2348

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant