robotpy / robotpy/robotpy-navx

[BUG]: segfault on Linux

Open
#35 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3
Forks
4
Avg merge
7d 5h
Merged PRs (30d)
1

Description

Problem description

Some memory corruption, so may not be navx's fault.

(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff76a8083 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x00007ffff764ef1e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7636902 in __GI_abort () at abort.c:79
#4  0x00007ffff7637767 in __libc_message_impl (fmt=fmt@entry=0x7ffff77c235b "%s\n") at ../sysdeps/posix/libc_fatal.c:132
#5  0x00007ffff76b21a5 in malloc_printerr (str=str@entry=0x7ffff77c0027 "corrupted size vs. prev_size") at malloc.c:5772
#6  0x00007ffff76b2c46 in unlink_chunk (p=<optimized out>, av=<optimized out>) at malloc.c:1611
#7  0x00007ffff76b2dd3 in malloc_consolidate (av=av@entry=0x7fffc0000030) at malloc.c:4876
#8  0x00007ffff76b59da in _int_malloc (av=av@entry=0x7fffc0000030, bytes=bytes@entry=64) at malloc.c:4468
#9  0x00007ffff76b6834 in __GI___libc_malloc (bytes=64) at malloc.c:3336
#10 0x00007fffe8ab83ec in operator new (sz=sz@entry=64) at ../../../../libstdc++-v3/libsupc++/new_op.cc:50
#11 0x00007fffe8da097c in __gnu_cxx::new_allocator<char const*>::allocate (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/11/ext/new_allocator.h:103
#12 std::allocator<char const*>::allocate (__n=<optimized out>, this=<optimized out>) at /usr/include/c++/11/bits/allocator.h:185
#13 std::allocator_traits<std::allocator<char const*> >::allocate (__n=<optimized out>, __a=...) at /usr/include/c++/11/bits/alloc_traits.h:464
#14 std::_Vector_base<char const*, std::allocator<char const*> >::_M_allocate (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/11/bits/stl_vector.h:346
#15 std::_Vector_base<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> >, std::allocator<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> > > >::_M_allocate (__n=<optimized out>, this=<optimized out>) at /usr/include/c++/11/bits/stl_vector.h:343
#16 std::vector<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> >, std::allocator<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> > > >::_M_realloc_insert<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> > > (
    this=this@entry=0x7fffc002d3f8, __position=std::unique_ptr<hal::SimDeviceData::Value> = {...}) at /usr/include/c++/11/bits/vector.tcc:440
#17 0x00007fffe8d9f2e8 in std::vector<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> >, std::allocator<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> > > >::emplace_back<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> > > (
    this=0x7fffc002d3f8) at /usr/include/c++/11/bits/vector.tcc:121
#18 wpi::UidVector<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> >, 16ul>::emplace_back<std::unique_ptr<hal::SimDeviceData::Value, std::default_delete<hal::SimDeviceData::Value> > > (this=0x7fffc002d3f8) at /work/wpiutil/src/main/native/include/wpi/UidVector.h:99
#19 hal::SimDeviceData::CreateValue (this=<optimized out>, device=<optimized out>, name=<optimized out>, direction=<optimized out>, numOptions=numOptions@entry=0, 
    options=options@entry=0x0, optionValues=<optimized out>, initialValue=...) at /work/hal/src/main/native/sim/mockdata/SimDeviceData.cpp:173
#20 0x00007fffe8d50175 in HAL_CreateSimValue (device=<optimized out>, name=<optimized out>, direction=<optimized out>, initialValue=<optimized out>)
    at /work/hal/src/main/native/sim/SimDevice.cpp:36
#21 0x00007fffd24b14b4 in SimIO::SimIO(unsigned char, IIOCompleteNotification*, hal::SimDevice*) ()
   from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#22 0x00007fffd24acea3 in AHRSJNI::SPIInit(unsigned int, unsigned char) () from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#23 0x00007fffd24a7949 in studica::AHRS::AHRS(studica::AHRS::NavXComType) () from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#24 0x00007fffd249fb3b in void std::_Construct<studica::AHRS, studica::AHRS::NavXComType>(studica::AHRS*, studica::AHRS::NavXComType&&) ()
   from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#25 0x00007fffd24942f8 in std::_Sp_counted_ptr_inplace<studica::AHRS, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<studica::AHRS::NavXComType>(std::allocator<void>, studica::AHRS::NavXComType&&) () from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#26 0x00007fffd248abe9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<studica::AHRS, std::allocator<void>, studica::AHRS::NavXComType>(studica::AHRS*&, std::_Sp_alloc_shared_tag<std::allocator<void> >, studica::AHRS::NavXComType&&) () from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#27 0x00007fffd247cd16 in std::__shared_ptr<studica::AHRS, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, studica::AHRS::NavXComType>(std::_Sp_alloc_shared_tag<std::allocator<void> >, studica::AHRS::NavXComType&&) () from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#28 0x00007fffd246f317 in std::shared_ptr<studica::AHRS>::shared_ptr<std::allocator<void>, studica::AHRS::NavXComType>(std::_Sp_alloc_shared_tag<std::allocator<void> >, studica::AHRS::NavXComType&&) () from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#29 0x00007fffd245e106 in std::shared_ptr<studica::AHRS> std::make_shared<studica::AHRS, studica::AHRS::NavXComType>(studica::AHRS::NavXComType&&) ()
   from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#30 0x00007fffd2450c2a in rpybuild_AHRS_initializer::finish()::{lambda()#1}::operator()() const ()
   from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
#31 0x00007fffd24943e2 in std::shared_ptr<studica::AHRS> pybind11::detail::argument_loader<>::call_impl<std::shared_ptr<studica::AHRS>, rpybuild_AHRS_initializer::finish()::{lambda()#1}&, , pybind11::gil_scoped_release>(rpybuild_AHRS_initializer::finish()::{lambda()#1}&, std::integer_sequence<unsigned long>, pybind11::gil_scoped_release&&) && ()
   from robotpy-navx/navx/_navx.cpython-312-x86_64-linux-gnu.so
Operating System

Linux

Installed Python Packages

Reproducible example code

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Linux gdb backtrace and inspect hal/src/main/native/sim/mockdata/SimDeviceData.cpp, /work/hal/src/main/native/sim/SimDevice.cpp, and wpiutil/src/main/native/include/wpi/UidVector.h. Reproduce the crash if possible through the navx Python extension; done means the Linux segfault is explained and a verified fix or minimal reproducer is available.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.