Git Product home page Git Product logo

sharedstructures's People

Contributors

fuzziqersoftware avatar jellezijlstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sharedstructures's Issues

Unaligned pointer causing UB

At this line:

Py_ssize_t chars_copied = PyUnicode_AsWideChar(
o, reinterpret_cast<wchar_t*>(res.as_string.data() + 1), count);

we create an unaligned 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?

Fails to build on Arch Linux: error: ignoring packed attribute because of unpacked non-POD field

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

Building Python Module

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!

Compliation errror due to reference and linking problems

I get the compliation errror:

/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

Question

How do I solve this :)

In cmakelists I do actually everything right:

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}
)

Maybe you can gfive me a hint, because this lib is perfectly suited for my problem. Thanks a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.