To reproduce:
1. Stand at the position 1695 36 -953 and wait (in the world here).
2. Game Crashes.
The following crash log was produced on the server:
Crash
[INFO] at std::__shared_count<[__gnu_cxx::_Lock_policy]2>::__shared_count[std::__weak_count<[__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::__shared_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2>::__shared_ptr[std::__weak_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::shared_ptr<POIInstance>::shared_ptr[std::weak_ptr<POIInstance> const&, std::nothrow_t] (UnknownFile:?)
at std::weak_ptr<POIInstance>::lock[] const (UnknownFile:?)
at Village::getBedPOICount[] const (UnknownFile:?)
at Village::tick[Tick, BlockSource&] (UnknownFile:?)
at VillageManager::tickVillages[Tick const&, Vec3 const&, BlockSource&] (UnknownFile:?)
at ServerPlayer::tickWorld[Tick const&] (UnknownFile:?)
at std::function<bool [Player&]>::operator[][Player&] const (UnknownFile:?)
at Level::forEachPlayer[std::function<bool [Player&]>] (UnknownFile:?)
at Level::tick[] (UnknownFile:?)
at ServerLevel::tick[] (UnknownFile:?)
at GameSession::tick[] (UnknownFile:?)
at Minecraft::tickSimtime[int, int] (UnknownFile:?)
at Minecraft::update[] (UnknownFile:?)
at ServerInstance::_update[] (UnknownFile:?)
at clone (UnknownFile:?)
From what I have discovered, this bug is caused by locking a weak_ptr from the POIInstance list (std::vector<std::weak_ptr<POIInstance>>). When reading from the vector using [], a null value is returned, which ultimately gets dereferenced and causes a crash. To be exact, the address+8 is dereferenced, which to my knowledge is the offset for the reference count of a smart pointer.
I can also see that right after locking the weak_ptr, there is some kind of null check (not sure if its for the same pointer though, I think not).
I propose the following: before locking the weak_ptr, check if it is nullptr. If not, then you can lock it. I don't know why any of the POIInstances should ever be nullpointers, but simply checking for this could solve the issue.
Related issues
Comments


Same problem, position [ 219 69 -688 ]
[INFO] Package: com.mojang.minecraft.dedicatedserver
Version: 1.16.201.2
OS: Linux
Server start: 2021-01-08 14:15:13 UTC
Dmp timestamp: 2021-01-08 14:17:05 UTC
Upload Date: 2021-01-08 14:17:05 UTC
Session ID: 86854841-37a9-422e-a10d-246184401b39
Commit hash:
Build id: development
CrashReporter Key: ce158104-660f-3b4f-9fe4-b690c05910a6
Crash
[INFO] at std::_shared_count<[__gnu_cxx::_Lock_policy]2>::shared_count[std::_weak_count<[__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::_shared_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2>::shared_ptr[std::_weak_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::shared_ptr<POIInstance>::shared_ptr[std::weak_ptr<POIInstance> const&, std::nothrow_t] (UnknownFile:?)
at std::weak_ptr<POIInstance>::lock[] const (UnknownFile:?)
at Village::getBedPOICount[] const (UnknownFile:?)
at Village::tick[Tick, BlockSource&] (UnknownFile:?)
at VillageManager::tickVillages[Tick const&, Vec3 const&, BlockSource&] (UnknownFile:?)
at ServerPlayer::tickWorld[Tick const&] (UnknownFile:?)
at std::function<bool [Player&]>::operator[][Player&] const (UnknownFile:?)
at Level::forEachPlayer[std::function<bool [Player&]>] (UnknownFile:?)
at Level::tick[] (UnknownFile:?)
at ServerLevel::tick[] (UnknownFile:?)
at GameSession::tick[] (UnknownFile:?)
at Minecraft::tickSimtime[int, int] (UnknownFile:?)
at Minecraft::update[] (UnknownFile:?)
at ServerInstance::_update[] (UnknownFile:?)
at clone (UnknownFile:?)

Added some comments in BDS-10666.
tl;dr: using the test world attached to this bug, I can reliably reproduce the crash under Ubuntu 20.04 but have not been able to reproduce under Ubuntu 18.04. I believe the difference is the version of libstdc++ (6.0.25 on Ubuntu 18.04; 6.0.28 on Ubuntu 20.04).
I'm testing using a Docker container and the standard Ubuntu provided images (ubuntu:18.04 and ubuntu:20.04).
Can you try this and see if it fixes the crash for you?

Added some comments in BDS-10666.
tl;dr: using the test world attached to this bug, I can reliably reproduce the crash under Ubuntu 20.04 but have not been able to reproduce under Ubuntu 18.04. I believe the difference is the version of libstdc++ (6.0.25 on Ubuntu 18.04; 6.0.28 on Ubuntu 20.04).
I'm testing using a Docker container and the standard Ubuntu provided images (ubuntu:18.04 and ubuntu:20.04).
Can you try this and see if it fixes the crash for you?

@Tom Gray my debian install where the crash occured is on libstdc+6.0.25. My personal computer, which has libstdc6.0.28 also crashes. I don't think this is an issue with any specific libstdc+ version.

@Tom Gray my debian install where the crash occured is on libstdc+6.0.25. My personal computer, which has libstdc6.0.28 also crashes. I don't think this is an issue with any specific libstdc+ version.

Same here - Ubuntu 20.04
[INFO] Package: com.mojang.minecraft.dedicatedserver
Version: 1.16.201.2
OS: Linux
Server start: 2021-01-09 17:06:40 UTC
Dmp timestamp: 2021-01-09 17:29:28 UTC
Upload Date: 2021-01-09 17:29:28 UTC
Session ID: 629e8872-5ead-4c07-a0af-0146148018e5
Commit hash:
Build id: development
CrashReporter Key: 2d02d684-d26e-3ee0-b5cd-52ae42c374db
Crash
[INFO] at std::_shared_count<[__gnu_cxx::_Lock_policy]2>::shared_count[std::_weak_count<[__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::_shared_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2>::shared_ptr[std::_weak_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::shared_ptr<POIInstance>::shared_ptr[std::weak_ptr<POIInstance> const&, std::nothrow_t] (UnknownFile:?)
at std::weak_ptr<POIInstance>::lock[] const (UnknownFile:?)
at Village::getBedPOICount[] const (UnknownFile:?)
at Village::tick[Tick, BlockSource&] (UnknownFile:?)
at VillageManager::tickVillages[Tick const&, Vec3 const&, BlockSource&] (UnknownFile:?)
at ServerPlayer::tickWorld[Tick const&] (UnknownFile:?)
at std::function<bool [Player&]>::operator[][Player&] const (UnknownFile:?)
at Level::forEachPlayer[std::function<bool [Player&]>] (UnknownFile:?)
at Level::tick[] (UnknownFile:?)
at ServerLevel::tick[] (UnknownFile:?)
at GameSession::tick[] (UnknownFile:?)
at Minecraft::tickSimtime[int, int] (UnknownFile:?)
at Minecraft::update[] (UnknownFile:?)
at ServerInstance::_update[] (UnknownFile:?)
at clone (UnknownFile:?)

Same here - Ubuntu 20.04
[INFO] Package: com.mojang.minecraft.dedicatedserver
Version: 1.16.201.2
OS: Linux
Server start: 2021-01-09 17:06:40 UTC
Dmp timestamp: 2021-01-09 17:29:28 UTC
Upload Date: 2021-01-09 17:29:28 UTC
Session ID: 629e8872-5ead-4c07-a0af-0146148018e5
Commit hash:
Build id: development
CrashReporter Key: 2d02d684-d26e-3ee0-b5cd-52ae42c374db
Crash
[INFO] at std::_shared_count<[__gnu_cxx::_Lock_policy]2>::shared_count[std::_weak_count<[__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::_shared_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2>::shared_ptr[std::_weak_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::shared_ptr<POIInstance>::shared_ptr[std::weak_ptr<POIInstance> const&, std::nothrow_t] (UnknownFile:?)
at std::weak_ptr<POIInstance>::lock[] const (UnknownFile:?)
at Village::getBedPOICount[] const (UnknownFile:?)
at Village::tick[Tick, BlockSource&] (UnknownFile:?)
at VillageManager::tickVillages[Tick const&, Vec3 const&, BlockSource&] (UnknownFile:?)
at ServerPlayer::tickWorld[Tick const&] (UnknownFile:?)
at std::function<bool [Player&]>::operator[][Player&] const (UnknownFile:?)
at Level::forEachPlayer[std::function<bool [Player&]>] (UnknownFile:?)
at Level::tick[] (UnknownFile:?)
at ServerLevel::tick[] (UnknownFile:?)
at GameSession::tick[] (UnknownFile:?)
at Minecraft::tickSimtime[int, int] (UnknownFile:?)
at Minecraft::update[] (UnknownFile:?)
at ServerInstance::_update[] (UnknownFile:?)
at clone (UnknownFile:?)

Thanks for confirming. I've put some more detail onΒ BDS-10666 with .so versions from my working install - can you compare these against your system?

Thanks for confirming. I've put some more detail onΒ BDS-10666 with .so versions from my working install - can you compare these against your system?
Thank you for your report!
We're actually already tracking this issue at BDS-10666, so we will resolve and link this ticket as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
Quick Links:
π Issue Guidelines β π¬ Mojang Support β π§ Suggestions β π Minecraft Wiki
Thank you for your report!
We're actually already tracking this issue at BDS-10666, so we will resolve and link this ticket as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
Quick Links:
π Issue Guidelines β π¬ Mojang Support β π§ Suggestions β π Minecraft Wiki
Same problem, position [ 219 69 -688 ]
[INFO] Package: com.mojang.minecraft.dedicatedserver
Version: 1.16.201.2
OS: Linux
Server start: 2021-01-08 14:15:13 UTC
Dmp timestamp: 2021-01-08 14:17:05 UTC
Upload Date: 2021-01-08 14:17:05 UTC
Session ID: 86854841-37a9-422e-a10d-246184401b39
Commit hash:
Build id: development
CrashReporter Key: ce158104-660f-3b4f-9fe4-b690c05910a6
Crash
[INFO] at std::_shared_count<[__gnu_cxx::_Lock_policy]2>::shared_count[std::_weak_count<[__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::_shared_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2>::shared_ptr[std::_weak_ptr<POIInstance, [__gnu_cxx::_Lock_policy]2> const&, std::nothrow_t] (UnknownFile:?)
at std::shared_ptr<POIInstance>::shared_ptr[std::weak_ptr<POIInstance> const&, std::nothrow_t] (UnknownFile:?)
at std::weak_ptr<POIInstance>::lock[] const (UnknownFile:?)
at Village::getBedPOICount[] const (UnknownFile:?)
at Village::tick[Tick, BlockSource&] (UnknownFile:?)
at VillageManager::tickVillages[Tick const&, Vec3 const&, BlockSource&] (UnknownFile:?)
at ServerPlayer::tickWorld[Tick const&] (UnknownFile:?)
at std::function<bool [Player&]>::operator[][Player&] const (UnknownFile:?)
at Level::forEachPlayer[std::function<bool [Player&]>] (UnknownFile:?)
at Level::tick[] (UnknownFile:?)
at ServerLevel::tick[] (UnknownFile:?)
at GameSession::tick[] (UnknownFile:?)
at Minecraft::tickSimtime[int, int] (UnknownFile:?)
at Minecraft::update[] (UnknownFile:?)
at ServerInstance::_update[] (UnknownFile:?)
at clone (UnknownFile:?)