-
Notifications
You must be signed in to change notification settings - Fork 87
[NOSQUASH] Remove the unnecessary sort in CNullDriver::addTexture #233
[NOSQUASH] Remove the unnecessary sort in CNullDriver::addTexture #233
Conversation
…eTexture * getTextureByIndex is pretty useless (apart from iterating over all texture, which we don't do), as you can't get an id. * renameTexture is broken anyway: The sort call does nothing because the array is still flagged as sorted.
|
(For the future) could this be refactored to use an unordered map? |
As I just found out here texture names are apparently not an one-to-one mapping to textures 🤔 |
If they are not supposed to be unique, we could still use an unordered multimap. |
Test_User/hax fixed this exact problem four months prior to this being posted, in a private fork we maintain, we also have numerous other fixes that still remain including an RCE exploit. |
The Irrlicht situation, visualized: @BeverlyCode Please feel free to forward such patches to upstream Irrlicht so that all forks could benefit from it. Fixes in private forks do not help anyone else. |
(Or just publicize your currently "private" fork, or parts of it, so we can take a look). Also feel free to responsibly disclose any vulnerabilities to us and/or Irrlicht as applicable. |
Sure I have messaged him about it, he doesn't like to use GitHub, but he's fairly active in the community I think for people the reach out to. I don't deal with Minetest much anymore but he pointed out to me today this was finally fixed in the main branch as he checks the main branch updates now and then. |
I looked through Irrlicht's commit history a bit, and it seemed to me like any (or at least most) recent security improvements (in loaders) stemmed from IrrlichtMT. Could you point to a specific commit, or as said, disclose the vulnerability to us? Are you sure there |
I made sure a few people got the core dumps and such, I can't remember what exactly it was other than Test_User found a memory leak where remote code could potentially write out of bounds. I don't think it was specifically Irrlicht code. I have tried to get a lot of Test_Users improvements committed to mainstream branches in the past, like I ensured his improvements to the Unified Inventory server load time got merged, that's a notable one. Usually I do my best at the time to get the word out, in some way at the time. Edit: oh yes I remember now I think it was the entity system, the same bug that was causing pipeworks to crash. there is a way you can trick it into overflowing memory if you know how, combined with a pet name tag or any formspec input that is not validated which seems to be a lot, arb code could be spammed into the entity list. Something like this, it was a while ago now. Test_User will know the full details or have a log of it to refer to if anyone wants the full details on that. |
Just had some messages from Test_User concerning his non-pushed changes to Minetest:
As a server operator I'd be inclined to say not to share the mapgen fix as it would give my server an advantage others do not, and in such a highly competitive server listing systems obviously this is completely reasonable. But I don't really care anymore. I don't think the players care about it that much either. There really is little incentive as a server operator to tell anyone about any fixes to the code, but I do every now and then anyway, it's never at my benefit and honestly usually at my loss, primarily its a loss of my time but also any communication with the Minetest community involves... a great deal of wasted time. (no I don't fancy pushing Test_User's changes to the main branch all the time sorry) There are many bugs in the code which will go unsolved for years, even though there have been multiple issues concerning them for years and everyone has been made aware they exist. They won't go solved for two primary reasons:
and to be honest I don't really like any of you. 🤷 |
Our primary concern are security-relevant issues in the engine or IrrlichtMt.
That is regrettable but it was your choice to comment here. |
TL;DR: A performance fix for faster client startup.
I've done some little profiling on client connect. Here's a flame graph showing Game::startup of a session where it took about 40 seconds to connect to a server:
The
std::__introsort_loop
is the sort of CNullDriver::Textures that we do for each texture. This sorting is unnecessary.CNullDriver::Textures holds an irr::core::array that is possibly sorted by texture name. Textures are accessed via binary search (see irrArray.h), which always sorts anyway. The comment that was already there also explains this.
CNullDriver::Textures is also not used by any child class, FYI.
Benchmarks (of Client::afterContentReceived, and Game::startup in parenthesis):
(I haven't run these often. Values are rounded.)
lightweight scenario (singleplayer mtg + mesecons):
before: 1.1 s (2.0 s)
after: 0.9 (1.8)
heavy scenario (some server):
before: 35.9 s (44.4 s)
after: 5.0 s (12.7 s)