Hello players,
found a big source of bugs, and I have to do another prebuild to test the fix.
http://files.star-made.org/build/pre/starmade-build_20131015_090732.zip
http://files.star-made.org/build/pre/starmade-build_20131015_152625.zip (fixed a long existing bug that caused the game stop displaying new segments)
http://files.star-made.org/build/pre/starmade-build_20131015_162228.zip (fixed GUI bug where in some resolutions the "click-area" would be incorrect. Apparently LWJGL Display resolutions aren't always pixel perfect)
(as always "dev" is pass/user. It will be installed on the test server play.star-made.org:4242. Other admins, please use prebuilds with care as they can contain gamebreaking bugs)
Description: There was a big bug in the file manager, as well as running conditions (unsafe operations when more then one thread has access to the same data). In starmade, a File manager is used to keep a certain amount of files open, so access can be as fast as possible, and each write/read operation doesn't have to open a file again (which causes big overhead). With multiple threads trying to access the open file, there are several unsave operations:
Sorry for the long text. I had to write it down to confirm the logic for myself.
Thank you for playing StarMade,
- schema
found a big source of bugs, and I have to do another prebuild to test the fix.
http://files.star-made.org/build/pre/starmade-build_20131015_090732.zip
http://files.star-made.org/build/pre/starmade-build_20131015_152625.zip (fixed a long existing bug that caused the game stop displaying new segments)
http://files.star-made.org/build/pre/starmade-build_20131015_162228.zip (fixed GUI bug where in some resolutions the "click-area" would be incorrect. Apparently LWJGL Display resolutions aren't always pixel perfect)
(as always "dev" is pass/user. It will be installed on the test server play.star-made.org:4242. Other admins, please use prebuilds with care as they can contain gamebreaking bugs)
Description: There was a big bug in the file manager, as well as running conditions (unsafe operations when more then one thread has access to the same data). In starmade, a File manager is used to keep a certain amount of files open, so access can be as fast as possible, and each write/read operation doesn't have to open a file again (which causes big overhead). With multiple threads trying to access the open file, there are several unsave operations:
- on the top level the simple read/write operations. A thread may not read while another thread is currently writing. This was fully functional since the last versions
- when a file is requested from cache, and does not exist in cache, it is opened and its header is read. Here was a problem, since another thread could come in with the same file request and issue another header read when the first file wasn't finished reading the same header and inserting the file into the cache. Here another lock was needed as well as a forced file synchronization (NIO File channel can defer writing operations) for the header, so all unwritten data is written to disk. This was also the reason for the NoHeaderExceptions, and a possible cause of corruption and chunk errors.
- when the limit (set by starmade) of open files is reached, the system will upon file request (and cache miss) close and remove the file from the cache, that was accessed the longest ago. Here was the bug: by keeping a local map for each game entity, the method that removed the file did it globally and then was attempting to remove that from its own cache. Now the file on the other hand was not necessary part of that cache to begin with, so basically the file while closed remained in the local cache of the entity that owned it. This is where the "FileNotFoundException: Having to reopen closed file" came from. The reopened file however was no longer in the global map: the removing removed it from global but tried to remove it from the wrong local map. So the file was no longer part of the "remove file that was accessed the longest ago" operation, and therefore remained open. This is a leak since if it happened more often the amount of open files that are no longer subject of being removed will rise over time, eventually slowing the OS down or causing the "Too many open files"-Exception, which is also dependent on the OS, and crashing the game.
- another running condition was a thread(A) reading while another thread(B) requested a whole other file (which is fine), but while doing so issued a "remove file that was accessed the longest ago" operation, because the limit of open files was reached: If in this case the file, that thread(A) is currently reading, was selected, thread(B) would close the file, and thread(A) would throw an exception reporting back to the game that no data was being read.
Sorry for the long text. I had to write it down to confirm the logic for myself.
Thank you for playing StarMade,
- schema