Commit Graph

26857 Commits (a9877aea984243bc04cf26b80320a7d96c22124f)
 

Author SHA1 Message Date
Petr Mikheev 6aab246879 Add ESM records that are needed to store Lua scripts configuration;
Use ptr.getType() (i.e. esm record names) instead of typeid(ptr.getClass()) in apps/openmw/mwlua.
3 years ago
Evil Eye 4ec927829f Give each reflect and spell absorption effect a chance to apply 3 years ago
psi29a 3006c496fc Merge branch 'morrowland_scripting' into 'master'
Morrowland scripting

Closes #6363

See merge request OpenMW/openmw!1318
3 years ago
psi29a c0dca5371b Merge branch 'recalc_mana' into 'master'
Don't wait a frame to recalculate magicka

Closes #3792

See merge request OpenMW/openmw!1323
3 years ago
psi29a 2765bcee5e Merge branch 'serialization' into 'master'
Add helpers for binary serialization

See merge request OpenMW/openmw!1319
3 years ago
glassmancody.info ba4f1921ab overrides 3 years ago
glassmancody.info 07e32c0fa6 remove object shader path 3 years ago
Evil Eye 289e1544d2 Don't wait a frame to recalculate magicka 3 years ago
psi29a e9f065222c Merge branch 'mac1015fix' into 'master'
Workaround MacOS failure for 10.15 by setting it to `allow_failure: true`

See merge request OpenMW/openmw!1322
3 years ago
Bret Curtis 3d0da9b9b2
Merge pull request #3191 from akortunov/warnfix
Fix some MSVC warnings
3 years ago
Bret Curtis ac02753da7
Merge pull request #3190 from akortunov/master
Fix showscenegraph warnings
3 years ago
psi29a 13b84ce798 Fix MacOS failure for 10.15 by setting it to `allow_failure: true` 3 years ago
Bo Svensson 1ff8318a52
refactors premultiplied alpha (#3189)
With this PR we refactor a `premultiplied alpha` user string set by `characterpreview.cpp` into a more flexible mechanism allowing us to assign any state to GUI textures. We can consider these changes more future proof than the previous approach.
3 years ago
Bo Svensson 7f9beac3a7
refactors a case insensitive map (#3184)
This PR aims to spark the retirement of a questionable pattern I have found all over our code base. I will illustrate how this pattern encourages code duplication, lacks type safety, requires documentation and can be prone to bugs.
```
std::map<std::string, Object> mMap; // Stored in all lowercase for a case-insensitive lookup

std::string lowerKey = Misc::StringUtils::lowerCase(key);
mMap.emplace(lowerKey, object);

std::string lowerKey = Misc::StringUtils::lowerCase(key);
mMap.find(lowerKey);

mMap.find(key); // Not found. Oops!
```
An alternative approach produces no such issues.
```
std::unordered_map<std::string, Object, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual> mMap;

mMap.emplace(key, object);

mMap.find(key);
```
Of course, such an alternative will work for a `map` as well, but an `unordered_map` is generally preferable over a `map` with these changes because we have moved `lowerCase` into the comparison operator. 

In this PR I have refactored `Animation::mNodeMap` accordingly. I have reviewed and adapted all direct and indirect usage of `Animation::mNodeMap` to ensure we do not change behaviour with this PR.
3 years ago
Bo Svensson 6fb376f1cf
templatise ptr.hpp (#3185)
With this PR we consolidate identical logic for Ptr and ConstPtr with the help of a template.
3 years ago
glassmancody.info 9cbbd2fff5 better transitions 3 years ago
Evil Eye fef902617a Parse integer format arguments as variable names 3 years ago
Andrei Kortunov 0f3c0cb0a0 Fix argument types mismatch 3 years ago
Andrei Kortunov 107a9ecb17 Fix variables hiding 3 years ago
elsid a58f1a94e3
Add helpers for binary serialization
To construct serializer from given entities:
* Data source/destination - any value that has to be serialized/deserialized,
  usually already existing type.
* Format - functional object to define high level serialization logic to
  define specific format and data schema. Like order of fields, allocation.
* Visitor - functional object to define low level serialization logic to
  operator on given data part.
  * BinaryWriter - copies given value into provided buffer.
  * BinaryReader - copies value into given destination from provided buffer.
  * SizeAccumulator - calculates required buffer size for given data.
3 years ago
Andrei Kortunov 566380c0d6 Fix showscenegraph warnings 3 years ago
glassmancody.info 1e40d27318 introduce sky shaders 3 years ago
Bret Curtis 62b59a3c00
Update CMakeLists.txt 3 years ago
Bo Svensson 41318a585f
fixes enable and disable commands (#3186)
This PR fixes a recent regression concerning enable and disable commands with object paging. In addition, we add a necessary comment to avoid such issues in the future.
3 years ago
Evil Eye 31aa19574b Make PositionCell take additional junk arguments 3 years ago
Evil Eye dfb6bdf77e Allow integer variable names 3 years ago
Evil Eye f70a154195 Merge branch 'place' of github.com:akortunov/openmw into master 3 years ago
Bret Curtis e65af0bf06
Silence all opengl deprecation warnings for MacOS
We know...
3 years ago
psi29a 217d17adeb Merge branch 'ugly_rounding' into 'master'
Prevent floating point issues accumulating

See merge request OpenMW/openmw!1306
3 years ago
Bo Svensson c9c8d02332
fixes a crash (#3183)
This PR fixes a crash caused by the improperly ensured lifetime of RigGeometry::mSourceGeometry. mSourceGeometry was not adequate to ensure mSourceGeometry would outlive mGeometry because we extend mGeometrys lifetime beyond this lifetime by passing mGeometry to the draw traversal instead of this.
In addition,

We add important comments.
We detect and prevent generally unsafe operations in high level code.
We add a sprinkling of const to help clarify intentions.
3 years ago
Evil Eye b5c876299d Round to a power of two 3 years ago
wareya e23b0edda4 Add pre-pass to collision trace function that traces over less distance if possible 3 years ago
elsid f2e43272e4 Merge branch 'master' into 'master'
Remove non-existent file from CMakeLists

See merge request OpenMW/openmw!1315
3 years ago
Fanael Linithien 07d505563e Remove non-existent file from CMakeLists 3 years ago
psi29a 1ffa02b2fd Merge branch 'fix_windows_tests' into 'master'
Fix tests on windows

See merge request OpenMW/openmw!1313
3 years ago
psi29a a4899d72f4 Merge branch 'deduplicate_swim_speed' into 'master'
Deduplicate swim speed formula implementation

See merge request OpenMW/openmw!1310
3 years ago
psi29a ed811176bc Merge branch 'fix_esm_loader' into 'master'
Fix logic expression for not found value in EsmLoader::getModel

See merge request OpenMW/openmw!1308
3 years ago
psi29a 0d810fe41c Merge branch 'init_gmst' into 'master'
Use lambda instead of bool to make sure GMST initialized once

See merge request OpenMW/openmw!1309
3 years ago
Alexei Kotov 156f2a471a Merge branch 'self_target' into 'master'
Apply on self effects on projectiles to the target instead

Closes #6321

See merge request OpenMW/openmw!1312
3 years ago
Alexei Kotov ccbc6d7b68 Merge branch 'arrow_on_target' into 'master'
Fix a regression involving default arguments

See merge request OpenMW/openmw!1311
3 years ago
elsid b5f0057ac9
Fix tests on windows 3 years ago
Evil Eye 63fa6d3b7c Apply on self effects on projectiles to the target instead 3 years ago
Evil Eye 31a7c83cc7 Fix a regression involving default arguments 3 years ago
elsid 68ed8487b5
Use lambda instead of bool to make sure GMST initialized once
This is less expensive than having 2 static variables and thread-safe.
3 years ago
elsid 2a0e1697b6
Deduplicate swim speed formula implementation 3 years ago
Bo Svensson a854a6e04a
removes UnrefQueue (#3181)
Currently, we use an `UnrefQueue` which supposedly aims to transfer destruction costs to another thread. The implications of this unusual pattern can not be well understood because some allocators might free resources more efficiently if they are freed by the same thread that allocated them. In addition, `UnrefQueue` complicates the validation of thread safety in our engine. Lastly, our current usage of `UnrefQueue` triggers `ref()`, `unref()` atomic operations as objects are passed into the queue. These operations could be more expensive than the actual destruction.

With this PR we thus remove `UnrefQueue`. We can expect these changes to have a minor impact at most because we free most resources elsewhere in `ResourceSystem::updateCache`.
3 years ago
elsid a3b6bc7263
Fix logic expression for not found value 3 years ago
elsid 562590720b
Remove ShadowsBin prototype on MWShadowTechnique destruction
To prevent crash:
==7733==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040000ca1b0 at pc 0x55fcfa8d1ee3 bp 0x7ffd1c464e00 sp 0x7ffd1c464df0
READ of size 4 at 0x6040000ca1b0 thread T0
    #0 0x55fcfa8d1ee2 in std::less<unsigned int>::operator()(unsigned int const&, unsigned int const&) const /usr/include/c++/11.1.0/bits/stl_function.h:386
    #1 0x55fcfa8d1ee2 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_lower_bound(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*, std::_Rb_tree_node_base*, unsigned int const&) /usr/include/c++/11.1.0/bits/stl_tree.h:1903
    #2 0x55fcfa8ca76e in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::lower_bound(unsigned int const&) /usr/include/c++/11.1.0/bits/stl_tree.h:1270
    #3 0x55fcfa8ca76e in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::lower_bound(unsigned int const&) /usr/include/c++/11.1.0/bits/stl_map.h:1259
    #4 0x55fcfa8ca76e in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::operator[](unsigned int const&) /usr/include/c++/11.1.0/bits/stl_map.h:497
    #5 0x55fcfa8ca76e in osg::getOrCreateContextData(unsigned int) /home/elsid/dev/OpenSceneGraph/src/osg/ContextData.cpp:142
    #6 0x55fcfab6848a in GLShaderManager* osg::get<GLShaderManager>(unsigned int) /home/elsid/dev/OpenSceneGraph/include/osg/ContextData:154
    #7 0x55fcfab6848a in osg::Shader::PerContextShader::~PerContextShader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:540
    #8 0x55fcfab68dc6 in osg::Shader::PerContextShader::~PerContextShader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:541
    #9 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #10 0x55fcfab6d0ce in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #11 0x55fcfab6d0ce in osg::ref_ptr<osg::Shader::PerContextShader>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #12 0x55fcfab6d0ce in void std::_Destroy<osg::ref_ptr<osg::Shader::PerContextShader> >(osg::ref_ptr<osg::Shader::PerContextShader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:140
    #13 0x55fcfab6d0ce in void std::_Destroy_aux<false>::__destroy<osg::ref_ptr<osg::Shader::PerContextShader>*>(osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:152
    #14 0x55fcfab6d0ce in void std::_Destroy<osg::ref_ptr<osg::Shader::PerContextShader>*>(osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:185
    #15 0x55fcfab6d0ce in void std::_Destroy<osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader> >(osg::ref_ptr<osg::Shader::PerContextShader>*, osg::ref_ptr<osg::Shader::PerContextShader>*, std::allocator<osg::ref_ptr<osg::Shader::PerContextShader> >&) /usr/include/c++/11.1.0/bits/alloc_traits.h:746
    #16 0x55fcfab6d0ce in std::vector<osg::ref_ptr<osg::Shader::PerContextShader>, std::allocator<osg::ref_ptr<osg::Shader::PerContextShader> > >::~vector() /usr/include/c++/11.1.0/bits/stl_vector.h:680
    #17 0x55fcfab6d0ce in osg::Shader::ShaderObjects::~ShaderObjects() /home/elsid/dev/OpenSceneGraph/include/osg/Shader:264
    #18 0x55fcfab6d0ce in osg::Shader::ShaderObjects::~ShaderObjects() /home/elsid/dev/OpenSceneGraph/include/osg/Shader:264
    #19 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #20 0x55fcfab6c532 in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #21 0x55fcfab6c532 in osg::ref_ptr<osg::Shader::ShaderObjects>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #22 0x55fcfab6c532 in void std::_Destroy<osg::ref_ptr<osg::Shader::ShaderObjects> >(osg::ref_ptr<osg::Shader::ShaderObjects>*) /usr/include/c++/11.1.0/bits/stl_construct.h:140
    #23 0x55fcfab6c532 in void std::_Destroy_aux<false>::__destroy<osg::ref_ptr<osg::Shader::ShaderObjects>*>(osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects>*) /usr/include/c++/11.1.0/bits/stl_construct.h:152
    #24 0x55fcfab6c532 in void std::_Destroy<osg::ref_ptr<osg::Shader::ShaderObjects>*>(osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects>*) /usr/include/c++/11.1.0/bits/stl_construct.h:185
    #25 0x55fcfab6c532 in void std::_Destroy<osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects> >(osg::ref_ptr<osg::Shader::ShaderObjects>*, osg::ref_ptr<osg::Shader::ShaderObjects>*, std::allocator<osg::ref_ptr<osg::Shader::ShaderObjects> >&) /usr/include/c++/11.1.0/bits/alloc_traits.h:746
    #26 0x55fcfab6c532 in std::vector<osg::ref_ptr<osg::Shader::ShaderObjects>, std::allocator<osg::ref_ptr<osg::Shader::ShaderObjects> > >::~vector() /usr/include/c++/11.1.0/bits/stl_vector.h:680
    #27 0x55fcfab6c532 in osg::buffered_value<osg::ref_ptr<osg::Shader::ShaderObjects> >::~buffered_value() /home/elsid/dev/OpenSceneGraph/include/osg/buffered_value:26
    #28 0x55fcfab6c532 in osg::Shader::~Shader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:271
    #29 0x55fcfab6c80a in osg::Shader::~Shader() /home/elsid/dev/OpenSceneGraph/src/osg/Shader.cpp:271
    #30 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #31 0x55fcfab185bd in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #32 0x55fcfab185bd in osg::ref_ptr<osg::Shader>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #33 0x55fcfab185bd in void std::_Destroy<osg::ref_ptr<osg::Shader> >(osg::ref_ptr<osg::Shader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:140
    #34 0x55fcfab185bd in void std::_Destroy_aux<false>::__destroy<osg::ref_ptr<osg::Shader>*>(osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:152
    #35 0x55fcfab185bd in void std::_Destroy<osg::ref_ptr<osg::Shader>*>(osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader>*) /usr/include/c++/11.1.0/bits/stl_construct.h:185
    #36 0x55fcfab185bd in void std::_Destroy<osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader> >(osg::ref_ptr<osg::Shader>*, osg::ref_ptr<osg::Shader>*, std::allocator<osg::ref_ptr<osg::Shader> >&) /usr/include/c++/11.1.0/bits/alloc_traits.h:746
    #37 0x55fcfab185bd in std::vector<osg::ref_ptr<osg::Shader>, std::allocator<osg::ref_ptr<osg::Shader> > >::~vector() /usr/include/c++/11.1.0/bits/stl_vector.h:680
    #38 0x55fcfab185bd in osg::Program::~Program() /home/elsid/dev/OpenSceneGraph/src/osg/Program.cpp:147
    #39 0x55fcfab18ae0 in osg::Program::~Program() /home/elsid/dev/OpenSceneGraph/src/osg/Program.cpp:147
    #40 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #41 0x55fcf8582cfa in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/Referenced:201
    #42 0x55fcf8582cfa in osg::ref_ptr<osg::StateAttribute>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/ref_ptr:44
    #43 0x55fcf8582cfa in std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int>::~pair() /usr/include/c++/11.1.0/bits/stl_pair.h:211
    #44 0x55fcf8582cfa in std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >::~pair() /usr/include/c++/11.1.0/bits/stl_pair.h:211
    #45 0x55fcf8582cfa in void __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::destroy<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >(std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >*) /usr/include/c++/11.1.0/ext/new_allocator.h:162
    #46 0x55fcf8582cfa in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > > >::destroy<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >(std::allocator<std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >&, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >*) /usr/include/c++/11.1.0/bits/alloc_traits.h:531
    #47 0x55fcf8582cfa in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:623
    #48 0x55fcf8582cfa in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::_M_drop_node(std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:631
    #49 0x55fcf8582cfa in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1889
    #50 0x55fcfac1f281 in std::_Rb_tree<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> >, std::_Select1st<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > >, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::clear() /usr/include/c++/11.1.0/bits/stl_tree.h:1254
    #51 0x55fcfac1f281 in std::map<std::pair<osg::StateAttribute::Type, unsigned int>, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int>, std::less<std::pair<osg::StateAttribute::Type, unsigned int> >, std::allocator<std::pair<std::pair<osg::StateAttribute::Type, unsigned int> const, std::pair<osg::ref_ptr<osg::StateAttribute>, unsigned int> > > >::clear() /usr/include/c++/11.1.0/bits/stl_map.h:1134
    #52 0x55fcfac1f281 in osg::StateSet::clear() /home/elsid/dev/OpenSceneGraph/src/osg/StateSet.cpp:738
    #53 0x55fcfac2079e in osg::StateSet::~StateSet() /home/elsid/dev/OpenSceneGraph/src/osg/StateSet.cpp:285
    #54 0x55fcfac20d3e in osg::StateSet::~StateSet() /home/elsid/dev/OpenSceneGraph/src/osg/StateSet.cpp:286
    #55 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #56 0x55fcfb20dcac in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/Referenced:201
    #57 0x55fcfb20dcac in osg::ref_ptr<osg::StateSet>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/build/gcc/asan/install/include/osg/ref_ptr:44
    #58 0x55fcfb20dcac in std::array<osg::ref_ptr<osg::StateSet>, 8ul>::~array() /usr/include/c++/11.1.0/array:95
    #59 0x55fcfb20dcac in SceneUtil::ShadowsBin::~ShadowsBin() /home/elsid/dev/openmw/components/sceneutil/shadowsbin.hpp:16
    #60 0x55fcfb20dcac in SceneUtil::ShadowsBin::~ShadowsBin() /home/elsid/dev/openmw/components/sceneutil/shadowsbin.hpp:16
    #61 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #62 0x55fcfa6cc17f in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #63 0x55fcfa6cc17f in osg::ref_ptr<osgUtil::RenderBin>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #64 0x55fcfa6cc17f in std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >::~pair() /usr/include/c++/11.1.0/bits/stl_pair.h:211
    #65 0x55fcfa6cc17f in void __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::destroy<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >(std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >*) /usr/include/c++/11.1.0/ext/new_allocator.h:162
    #66 0x55fcfa6cc17f in void std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > > >::destroy<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >(std::allocator<std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >&, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >*) /usr/include/c++/11.1.0/bits/alloc_traits.h:531
    #67 0x55fcfa6cc17f in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_destroy_node(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:623
    #68 0x55fcfa6cc17f in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_drop_node(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:631
    #69 0x55fcfa6cc17f in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1889
    #70 0x55fcfa6cc122 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1887
    #71 0x55fcfa6cc122 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::_M_erase(std::_Rb_tree_node<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1887
    #72 0x55fcfa6cc245 in std::_Rb_tree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> >, std::_Select1st<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::~_Rb_tree() /usr/include/c++/11.1.0/bits/stl_tree.h:984
    #73 0x55fcfa6cc245 in std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, osg::ref_ptr<osgUtil::RenderBin>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, osg::ref_ptr<osgUtil::RenderBin> > > >::~map() /usr/include/c++/11.1.0/bits/stl_map.h:302
    #74 0x55fcfa6cc245 in RenderBinPrototypeList::~RenderBinPrototypeList() /home/elsid/dev/OpenSceneGraph/src/osgUtil/RenderBin.cpp:48
    #75 0x55fcfa6cc245 in RenderBinPrototypeList::~RenderBinPrototypeList() /home/elsid/dev/OpenSceneGraph/src/osgUtil/RenderBin.cpp:48
    #76 0x55fcfab4a3f3 in osg::Referenced::signalObserversAndDelete(bool, bool) const /home/elsid/dev/OpenSceneGraph/src/osg/Referenced.cpp:292
    #77 0x55fcfa6cbcc1 in osg::Referenced::unref() const /home/elsid/dev/OpenSceneGraph/include/osg/Referenced:201
    #78 0x55fcfa6cbcc1 in osg::ref_ptr<RenderBinPrototypeList>::~ref_ptr() /home/elsid/dev/OpenSceneGraph/include/osg/ref_ptr:44
    #79 0x7f3977bd04a6 in __run_exit_handlers (/usr/lib/libc.so.6+0x3f4a6)
    #80 0x7f3977bd064d in exit (/usr/lib/libc.so.6+0x3f64d)
    #81 0x7f3977bb8b2b in __libc_start_main (/usr/lib/libc.so.6+0x27b2b)
    #82 0x55fcf81ea12d in _start (/home/elsid/dev/openmw/build/gcc/asan/openmw+0xa4412d)

0x6040000ca1b0 is located 32 bytes inside of 48-byte region [0x6040000ca190,0x6040000ca1c0)
freed by thread T0 here:
    #0 0x7f397a633d69 in operator delete(void*, unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cpp:172
    #1 0x55fcfa8d1824 in __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::deallocate(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*, unsigned long) /usr/include/c++/11.1.0/ext/new_allocator.h:139
    #2 0x55fcfa8d1824 in std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > > >::deallocate(std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >&, std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*, unsigned long) /usr/include/c++/11.1.0/bits/alloc_traits.h:492
    #3 0x55fcfa8d1824 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_put_node(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:565
    #4 0x55fcfa8d1824 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_drop_node(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:632
    #5 0x55fcfa8d1824 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_erase(std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >*) /usr/include/c++/11.1.0/bits/stl_tree.h:1889
    #6 0x55fcfa8d18da in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::~_Rb_tree() /usr/include/c++/11.1.0/bits/stl_tree.h:984
    #7 0x55fcfa8d18da in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::~map() /usr/include/c++/11.1.0/bits/stl_map.h:302
    #8 0x7f3977bd04a6 in __run_exit_handlers (/usr/lib/libc.so.6+0x3f4a6)

previously allocated by thread T0 here:
    #0 0x7f397a632ca1 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cpp:99
    #1 0x55fcfa8d3aa1 in __gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::allocate(unsigned long, void const*) /usr/include/c++/11.1.0/ext/new_allocator.h:121
    #2 0x55fcfa8d3aa1 in std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > > >::allocate(std::allocator<std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >&, unsigned long) /usr/include/c++/11.1.0/bits/alloc_traits.h:460
    #3 0x55fcfa8d3aa1 in std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_get_node() /usr/include/c++/11.1.0/bits/stl_tree.h:561
    #4 0x55fcfa8d3aa1 in std::_Rb_tree_node<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >* std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_create_node<std::piecewise_construct_t const&, std::tuple<unsigned int const&>, std::tuple<> >(std::piecewise_construct_t const&, std::tuple<unsigned int const&>&&, std::tuple<>&&) /usr/include/c++/11.1.0/bits/stl_tree.h:611
    #5 0x55fcfa8d3aa1 in std::_Rb_tree_iterator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > std::_Rb_tree<unsigned int, std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> >, std::_Select1st<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<unsigned int const&>, std::tuple<> >(std::_Rb_tree_const_iterator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > >, std::piecewise_construct_t const&, std::tuple<unsigned int const&>&&, std::tuple<>&&) /usr/include/c++/11.1.0/bits/stl_tree.h:2429
    #6 0x55fcfa8cfd91 in std::map<unsigned int, osg::ref_ptr<osg::ContextData>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, osg::ref_ptr<osg::ContextData> > > >::operator[](unsigned int const&) /usr/include/c++/11.1.0/bits/stl_map.h:501
    #7 0x55fcfa8cfd91 in osg::ContextData::createNewContextID() /home/elsid/dev/OpenSceneGraph/src/osg/ContextData.cpp:171
    #8 0x55fcfa9be218 in osg::GraphicsContext::createNewContextID() /home/elsid/dev/OpenSceneGraph/src/osg/GraphicsContext.cpp:320
    #9 0x55fcfb68d1ef in SDLUtil::GraphicsWindowSDL2::GraphicsWindowSDL2(osg::GraphicsContext::Traits*) /home/elsid/dev/openmw/components/sdlutil/sdlgraphicswindow.cpp:39
    #10 0x55fcfa17f93a in OMW::Engine::createWindow(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:611
    #11 0x55fcfa18398f in OMW::Engine::prepareEngine(Settings::Manager&) /home/elsid/dev/openmw/apps/openmw/engine.cpp:679
    #12 0x55fcfa18c4f2 in OMW::Engine::go() /home/elsid/dev/openmw/apps/openmw/engine.cpp:949
    #13 0x55fcfa13c9ff in runApplication(int, char**) /home/elsid/dev/openmw/apps/openmw/main.cpp:316
    #14 0x55fcfb49f562 in wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/elsid/dev/openmw/components/debug/debugging.cpp:205
    #15 0x55fcfa133114 in main /home/elsid/dev/openmw/apps/openmw/main.cpp:328
    #16 0x7f3977bb8b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/11.1.0/bits/stl_function.h:386 in std::less<unsigned int>::operator()(unsigned int const&, unsigned int const&) const
Shadow bytes around the buggy address:
  0x0c08800113e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c08800113f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011410: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011420: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c0880011430: fa fa fd fd fd fd[fd]fd fa fa fa fa fa fa fa fa
  0x0c0880011440: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011450: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011460: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011470: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c0880011480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==7733==ABORTING
3 years ago
elsid 590a340e6e
Remove redundant ShadowsBin::sCastingPrograms
This variable is only used in ShadowsBin constructor and it's initialized each
time before constructor call so required value can be just passed into
ShadowsBin ctor.

Make ShadowsBin default constructor private because it is required by osg even
it's not actually called.
3 years ago
elsid 9d1b7c4a30
Use type alias to avoid long type names and length redefinition for array 3 years ago