adepierre / Botcraft

Botcraft is a cross-platform C++ library to create bots that connect and interact with Minecraft servers with (optional) integrated OpenGL renderer
GNU General Public License v3.0
405 stars 43 forks source link

example 5 crashes #147

Closed folkertvanheusden closed 2 months ago

folkertvanheusden commented 2 months ago

Is this enough info?

[2024-07-26 00:05:44.269] [WARNING] [main(140737353672576)] ManagersClient.cpp(42): Your version of botcraft hasn't been compiled with GUI enabled, setting use_renderer_ to false
[2024-07-26 00:05:44.270] [INFO] [main(140737353672576)] AssetsManager.cpp(36): Loading blocks from file...
[2024-07-26 00:06:01.107] [INFO] [main(140737353672576)] AssetsManager.cpp(38): Done!
[2024-07-26 00:06:01.108] [INFO] [main(140737353672576)] AssetsManager.cpp(39): Loading biomes from file...
[2024-07-26 00:06:01.155] [INFO] [main(140737353672576)] AssetsManager.cpp(41): Done!
[2024-07-26 00:06:01.155] [INFO] [main(140737353672576)] AssetsManager.cpp(42): Loading items from file...
[2024-07-26 00:06:01.259] [INFO] [main(140737353672576)] AssetsManager.cpp(44): Done!
[2024-07-26 00:06:01.259] [INFO] [main(140737353672576)] AssetsManager.cpp(54): Clearing cache from memory...
[2024-07-26 00:06:01.301] [INFO] [main(140737353672576)] AssetsManager.cpp(56): Done!
[2024-07-26 00:06:01.302] [INFO] [main(140737353672576)] main.cpp(70): Starting connection process
[2024-07-26 00:06:01.309] [INFO] [main(140737353672576)] Authentifier.cpp(86): Cached Minecraft token for Microsoft account still valid.
[2024-07-26 00:06:01.310] [INFO] [main(140737353672576)] Authentifier.cpp(89): Getting player certificates...
[2024-07-26 00:06:01.312] [INFO] [main(140737353672576)] Authentifier.cpp(1159): Cached player certificates still valid!
[2024-07-26 00:06:01.312] [INFO] [main(140737353672576)] Authentifier.cpp(96): Player certificates obtained!
[New Thread 0x7ffff54006c0 (LWP 23573)]
[2024-07-26 00:06:01.316] [INFO] [main(140737353672576)] TCP_Com.cpp(249): Performing SRV DNS lookup on _minecraft._tcp.172.29.0.130 to find an endpoint
[2024-07-26 00:06:01.339] [WARNING] [main(140737353672576)] TCP_Com.cpp(312): SRV DNS lookup failed to find an address
[2024-07-26 00:06:01.340] [INFO] [main(140737353672576)] TCP_Com.cpp(31): Trying to connect to 172.29.0.130:25565
[New Thread 0x7ffff4a006c0 (LWP 23575)]
[2024-07-26 00:06:01.355] [INFO] [NetworkIOService(140737297516224)] TCP_Com.cpp(97): Connection to server established.
[New Thread 0x7fffefe006c0 (LWP 23592)]
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2
[New Thread 0x7fffef4006c0 (LWP 23597)]
[2024-07-26 00:06:03.085] [INFO] [Behaviour - McAutoBot123(140737217824448)] TemplatedBehaviourClient.hpp(219): Behaviour tree changed (anonymous tree)

Thread 4 "5_MobHitterExam" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffefe006c0 (LWP 23592)]
___pthread_rwlock_rdlock (rwlock=0x8) at ./nptl/pthread_rwlock_rdlock.c:26
warning: 26 ./nptl/pthread_rwlock_rdlock.c: No such file or directory
(gdb) bt
#0  ___pthread_rwlock_rdlock (rwlock=0x8) at ./nptl/pthread_rwlock_rdlock.c:26
#1  0x00007ffff7bf56b3 in std::__glibcxx_rwlock_rdlock (__rwlock=0x8) at /usr/include/c++/13/shared_mutex:81
#2  0x00007ffff7bf5758 in std::__shared_mutex_pthread::lock_shared (this=0x8) at /usr/include/c++/13/shared_mutex:232
#3  0x00007ffff7bf57ee in std::shared_mutex::lock_shared (this=0x8) at /usr/include/c++/13/shared_mutex:429
#4  0x00007ffff7bf6c97 in std::shared_lock<std::shared_mutex>::shared_lock (this=0x7fffefdff350, __m=...) at /usr/include/c++/13/shared_mutex:741
#5  0x00007ffff7ceb11e in Botcraft::Entity::GetPosition (this=0x0) at /home/folkert/t/Botcraft/botcraft/src/Game/Entities/entities/Entity.cpp:768
#6  0x000055555557707a in HitCloseHostiles (c=...) at /home/folkert/t/Botcraft/Examples/5_MobHitterExample/src/MobHitterTasks.cpp:20
#7  0x000055555558b781 in std::__invoke_impl<Botcraft::Status, Botcraft::Status (*&)(Botcraft::BehaviourClient&), Botcraft::SimpleBehaviourClient&> (
    __f=@0x5555555b23b8: 0x555555576f19 <HitCloseHostiles(Botcraft::BehaviourClient&)>) at /usr/include/c++/13/bits/invoke.h:61
#8  0x000055555558b57e in std::__invoke_r<Botcraft::Status, Botcraft::Status (*&)(Botcraft::BehaviourClient&), Botcraft::SimpleBehaviourClient&> (
    __fn=@0x5555555b23b8: 0x555555576f19 <HitCloseHostiles(Botcraft::BehaviourClient&)>) at /usr/include/c++/13/bits/invoke.h:114
#9  0x000055555558b3eb in std::_Function_handler<Botcraft::Status (Botcraft::SimpleBehaviourClient&), Botcraft::Status (*)(Botcraft::BehaviourClient&)>::_M_invoke(std::_Any_data const&, Botcraft::SimpleBehaviourClient&) (__functor=..., __args#0=...) at /usr/include/c++/13/bits/std_function.h:290
#10 0x000055555558ca2b in std::function<Botcraft::Status (Botcraft::SimpleBehaviourClient&)>::operator()(Botcraft::SimpleBehaviourClient&) const (
    this=0x5555555b23b8, __args#0=...) at /usr/include/c++/13/bits/std_function.h:591
#11 0x000055555558c4a2 in Botcraft::Leaf<Botcraft::SimpleBehaviourClient>::TickImpl (this=0x5555555b2390, context=...)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:207
#12 0x0000555555586620 in Botcraft::Node<Botcraft::SimpleBehaviourClient>::Tick (this=0x5555555b2390, context=...)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:40
#13 0x000055555558cddd in Botcraft::Composite<Botcraft::SimpleBehaviourClient>::TickChild (this=0x5555555b2330, context=..., index=0)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:102
#14 0x000055555558c7b9 in Botcraft::Sequence<Botcraft::SimpleBehaviourClient>::TickImpl (this=0x5555555b2330, context=...)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:293
#15 0x0000555555586620 in Botcraft::Node<Botcraft::SimpleBehaviourClient>::Tick (this=0x5555555b2330, context=...)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:40
#16 0x000055555558c0b0 in Botcraft::BehaviourTree<Botcraft::SimpleBehaviourClient>::TickImpl (this=0x5555555b24f0, context=...)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:263
#17 0x0000555555586620 in Botcraft::Node<Botcraft::SimpleBehaviourClient>::Tick (this=0x5555555b24f0, context=...)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/BehaviourTree.hpp:40
#18 0x0000555555584fdd in Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::TreeLoop (this=0x7fffffffdab0)
    at /home/folkert/t/Botcraft/botcraft/include/botcraft/AI/TemplatedBehaviourClient.hpp:280
#19 0x000055555558d4d0 in std::__invoke_impl<void, void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(), Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>*> (
    __f=@0x55555769adf0: (void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(class Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient> * const)) 0x555555584ed6 <Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::TreeLoop()>, 
--Type <RET> for more, q to quit, c to continue without paging--
    __t=@0x55555769ade8: 0x7fffffffdab0) at /usr/include/c++/13/bits/invoke.h:74
#20 0x000055555558d423 in std::__invoke<void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(), Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>*> (
    __fn=@0x55555769adf0: (void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(class Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient> * const)) 0x555555584ed6 <Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::TreeLoop()>)
    at /usr/include/c++/13/bits/invoke.h:96
#21 0x000055555558d349 in std::thread::_Invoker<std::tuple<void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(), Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>*> >::_M_invoke<0ul, 1ul> (this=0x55555769ade8) at /usr/include/c++/13/bits/std_thread.h:292
#22 0x000055555558c862 in std::thread::_Invoker<std::tuple<void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(), Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>*> >::operator() (this=0x55555769ade8) at /usr/include/c++/13/bits/std_thread.h:299
#23 0x000055555558be70 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>::*)(), Botcraft::TemplatedBehaviourClient<Botcraft::SimpleBehaviourClient>*> > >::_M_run (this=0x55555769ade0)
    at /usr/include/c++/13/bits/std_thread.h:244
#24 0x00007ffff60eabb4 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#25 0x00007ffff5c9ca94 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
#26 0x00007ffff5d29c3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
adepierre commented 2 months ago

Thanks for the report. I confirm I can reproduce the issue. I'll try to take a look to see what's going on

adepierre commented 2 months ago

Solved by d28b7aaf99e09943df21b19e34d47acfb81b1904