fuzziqersoftware / sharedstructures Goto Github PK
View Code? Open in Web Editor NEWDynamically-sized shared-memory data structures in C++ and Python 3
License: MIT License
Dynamically-sized shared-memory data structures in C++ and Python 3
License: MIT License
At this line:
sharedstructures/src/PythonModule.cc
Lines 163 to 164 in bebf539
wchar_t*
pointer, because we add 1 byte to a valid pointer. As I understand it, this is undefined behavior, because C and C++ require all pointers to be aligned to their size. I ran into this after I compiled a new Python binary, and for whatever reason gcc (7.5.0) started emitting code that depends on the pointer being properly aligned. I spent some quality time with gdb and tracked it down to the unaligned pointer generated by sharedstructures.
It's not immediately obvious to me how to fix the bug. Does sharedstructures rely on having pointers offset by 1 byte?
Having trouble building on Arch Linux.
$ make
[ 3%] Building CXX object CMakeFiles/sharedstructures.dir/src/Allocator.cc.o
In file included from /tmp/sharedstructures/src/Allocator.hh:5,
from /tmp/sharedstructures/src/Allocator.cc:1:
/tmp/sharedstructures/src/Pool.hh:191:27: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<long unsigned int> sharedstructures::Pool::Data::size’ [-Werror]
191 | std::atomic<uint64_t> size;
| ^~~~
In file included from /tmp/sharedstructures/src/Allocator.hh:6:
/tmp/sharedstructures/src/ProcessLock.hh:11:24: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessLock::lock’ [-Werror]
11 | std::atomic<int32_t> lock;
| ^~~~
/tmp/sharedstructures/src/ProcessLock.hh:18:24: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessReadWriteLock::write_lock’ [-Werror]
18 | std::atomic<int32_t> write_lock;
| ^~~~~~~~~~
/tmp/sharedstructures/src/ProcessLock.hh:19:24: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessReadWriteLock::reader_tokens [65]’ [-Werror]
19 | std::atomic<int32_t> reader_tokens[NUM_READER_SLOTS];
| ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/sharedstructures.dir/build.make:76: CMakeFiles/sharedstructures.dir/src/Allocator.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/sharedstructures.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
I've attached the output of my cmake .
. (too big to paste in)
sharedstructures_cmake.txt
Hi Guys,
I'm using Ubuntu 20.04, but python cannot find the module (ModuleNotFoundError: No module named 'sharedstructures') and neither can I on my OS.
I get the messages from cmake:
-- Building Python module
-- FIND_PACKAGE_MESSAGE_DETAILS_Python3=[/usr/bin/python3.9][/usr/lib/x86_64-linux-gnu/libpython3.9.so][/usr/include/python3.9][cfound components: Interpreter Development ][v3.9.5()]
Thanks for a hint!
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(LogarithmicAllocator.cc.o): in function
sharedstructures::LogarithmicAllocator::verify() const':
/home/ilja/sharedstructures/src/LogarithmicAllocator.cc:514: undefined reference to string_printf[abi:cxx11](char const*, ...)' /usr/bin/ld: /home/ilja/sharedstructures/src/LogarithmicAllocator.cc:519: undefined reference to
string_printf[abi:cxx11](char const*, ...)'
/usr/bin/ld: /home/ilja/sharedstructures/src/LogarithmicAllocator.cc:523: undefined reference to string_printf[abi:cxx11](char const*, ...)' /usr/bin/ld: /home/ilja/sharedstructures/src/LogarithmicAllocator.cc:531: undefined reference to
string_printf[abi:cxx11](char const*, ...)'
/usr/bin/ld: /home/ilja/sharedstructures/src/LogarithmicAllocator.cc:540: undefined reference to string_printf[abi:cxx11](char const*, ...)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(LogarithmicAllocator.cc.o):/home/ilja/sharedstructures/src/LogarithmicAllocator.cc:545: more undefined references to
string_printf[abi:cxx11](char const*, ...)' follow
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::open_segment(char const*, int, unsigned int, bool)': /home/ilja/sharedstructures/src/Pool.cc:20: undefined reference to
shm_open'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::unlink_segment(char const*, bool)': /home/ilja/sharedstructures/src/Pool.cc:28: undefined reference to
shm_unlink'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::Pool::Pool(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, bool)': /home/ilja/sharedstructures/src/Pool.cc:34: undefined reference to
scoped_fd::scoped_fd()'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:45: undefined reference to scoped_fd::operator=(int)' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:46: undefined reference to
scoped_fd::operator int() const'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:47: undefined reference to scoped_fd::operator=(int)' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:48: undefined reference to
scoped_fd::operator int() const'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:49: undefined reference to cannot_open_file::cannot_open_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:53: undefined reference to
scoped_fd::operator int() const'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:53: undefined reference to fstat(int)' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:59: undefined reference to
scoped_fd::operator int() const'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:69: undefined reference to scoped_fd::operator int() const' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:72: undefined reference to
string_for_errorabi:cxx11'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:75: undefined reference to scoped_fd::operator int() const' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:34: undefined reference to
scoped_fd::~scoped_fd()'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::Pool::~Pool()': /home/ilja/sharedstructures/src/Pool.cc:86: undefined reference to
scoped_fd::~scoped_fd()'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::Pool::expand(unsigned long)': /home/ilja/sharedstructures/src/Pool.cc:108: undefined reference to
scoped_fd::operator int() const'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:109: undefined reference to string_for_error[abi:cxx11](int)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function
sharedstructures::Pool::check_size_and_remap() const':
/home/ilja/sharedstructures/src/Pool.cc:120: undefined reference to scoped_fd::operator int() const' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:120: undefined reference to
fstat(int)'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:126: undefined reference to scoped_fd::operator int() const' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:129: undefined reference to
string_for_errorabi:cxx11'
/usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:130: undefined reference to scoped_fd::operator int() const' /usr/bin/ld: /home/ilja/sharedstructures/src/Pool.cc:131: undefined reference to
string_printf[abi:cxx11](char const*, ...)'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::Pool::map_and_call(unsigned long, unsigned long, std::function<void (void*, unsigned long)>)': /home/ilja/sharedstructures/src/Pool.cc:148: undefined reference to
scoped_fd::operator int() const'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(Pool.cc.o): in function sharedstructures::Pool::delete_pool(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)': /home/ilja/sharedstructures/src/Pool.cc:166: undefined reference to
string_for_errorabi:cxx11'
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(PrefixTree.cc.o): in function sharedstructures::PrefixTree::LookupResult::str[abi:cxx11]() const': /home/ilja/sharedstructures/src/PrefixTree.cc:107: undefined reference to
string_printf[abi:cxx11](char const*, ...)'
/usr/bin/ld: /home/ilja/sharedstructures/src/PrefixTree.cc:109: undefined reference to string_printf[abi:cxx11](char const*, ...)' /usr/bin/ld: /home/ilja/sharedstructures/src/PrefixTree.cc:111: undefined reference to
string_printf[abi:cxx11](char const*, ...)'
/usr/bin/ld: /home/ilja/sharedstructures/src/PrefixTree.cc:113: undefined reference to string_printf[abi:cxx11](char const*, ...)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(PrefixTree.cc.o): in function
sharedstructures::PrefixTree::get_structure_for_contents[abi:cxx11](unsigned long) const':
/home/ilja/sharedstructures/src/PrefixTree.cc:1447: undefined reference to string_printf[abi:cxx11](char const*, ...)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(PrefixTree.cc.o):/home/ilja/sharedstructures/src/PrefixTree.cc:1456: more undefined references to
string_printf[abi:cxx11](char const*, ...)' follow
/usr/bin/ld: /usr/local/lib/libsharedstructures.a(ProcessLock.cc.o): in function sharedstructures::this_process_token()': /home/ilja/sharedstructures/src/ProcessLock.cc:63: undefined reference to
getpid_cached()'
/usr/bin/ld: /usr[ 3%] Built target sensor_msgs_generate_messages_eus
/local/lib/libsharedstructures.a(ProcessLock.cc.o): in function sharedstructures::process_for_token_is_running(int)': /home/ilja/sharedstructures/src/ProcessLock.cc:89: undefined reference to
pid_exists(int)'
/usr/bin/ld: /home/ilja/sharedstructures/src/ProcessLock.cc:92: undefined reference to pid_is_zombie(int)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(ProcessLock.cc.o): in function
sharedstructures::futex_wait(std::atomic, int, timespec const)':
/home/ilja/sharedstructures/src/ProcessLock.cc:115: undefined reference to string_for_error[abi:cxx11](int)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(ProcessLock.cc.o): in function
sharedstructures::futex_wake(std::atomic, int)':
/home/ilja/sharedstructures/src/ProcessLock.cc:122: undefined reference to string_for_error[abi:cxx11](int)' /usr/bin/ld: /usr/local/lib/libsharedstructures.a(ProcessLock.cc.o): in function
sharedstructures::wait_for_reader_drain(sharedstructures::ProcessReadWriteLock, bool)':
/home/ilja/sharedstructures/src/ProcessLock.cc:242: undefined reference to getpid_cached()' collect2: error: ld returned 1 exit status make[2]: *** [01_gpr/mmcl_cpp_particle_weight/CMakeFiles/example_sharedmemory_node.dir/build.make:107: /home/ilja/01_lobabo_ego_ws/ros1/devel/lib/mmcl_cpp_particle_weight/example_sharedmemory_node] Error 1 make[1]: *** [CMakeFiles/Makefile2:7672: 01_gpr/mmcl_cpp_particle_weight/CMakeFiles/example_sharedmemory_node.dir/all] Error 2
How do I solve this :)
find_library(ARRAY_LIBRARY sharedstructures PATHS /usr/lib /usr/local/lib)
include_directories(
include
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
/home/ilja/sharedstructures/src
/home/ilja/sharedstructures
)
target_link_libraries(example_sharedmemory_node
${catkin_LIBRARIES}
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY}
${RT_LIBRARY}
/usr/local/lib/libsharedstructures.a
${ARRAY_LIBRARY}
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.