Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `exception_memory::__cxx::cxa_free_exception(void*)' #2

Open
EleonoreJ opened this issue Sep 19, 2022 · 3 comments

Comments

@EleonoreJ
Copy link

I had the following issue when trying to compile the static_exception library:
CMake Warning at /usr/src/gtest/CMakeLists.txt:54 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.

static_exception/test/static_exception_test.cpp:37:20: warning: inline function ‘void exception_memory::__cxx::cxa_free_exception(void*)’ used but never defined
37 | extern inline void cxa_free_exception(void vptr) noexcept;
| ^~~~~~~~~~~~~~~~~~
static_exception/test/static_exception_test.cpp:36:20: warning: inline function ‘void exception_memory::__cxx::cxa_free_dependent_exception(void
)’ used but never defined
36 | extern inline void cxa_free_dependent_exception (void vptr) noexcept;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: CMakeFiles/static_exception_test.dir/static_exception_test.cpp.o: in function StaticExceptions_MemoryLeak_Test::TestBody()': static_exception/test/static_exception_test.cpp:193: undefined reference to exception_memory::__cxx::cxa_free_exception(void
)'
/usr/bin/ld: static_exception/test/static_exception_test.cpp:194: undefined reference to `exception_memory::__cxx::cxa_free_dependent_exception(void*)'
collect2: error: ld returned 1 exit status
make[2]: *** [test/CMakeFiles/static_exception_test.dir/build.make:90: test/static_exception_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:153: test/CMakeFiles/static_exception_test.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

I used colcon build to build it.
gcc/g++ version are: 9.4.0.

Do you have any idea on how to solve this?
Thank you!

@flynneva
Copy link
Contributor

@EleonoreJ good catch! Looks like there was a missing #include <cstdlib> in there somehow. I've opened up #3 with the fix as well as added some CI to check for these types of errors in the future. Feel free to use the CI script as a template on how to build and run the repo.

@EleonoreJ
Copy link
Author

EleonoreJ commented Oct 10, 2022

@flynneva Thank you for answering!
I am able to run cmake .. and make and then the tests.
But, when I try to do colcon build, I still have the same issue, am I missing something?
And quick question: is it compliant with hard real-time requirements?
Do you know if it violates some Autosar's rules?
Many thanks!

@flynneva
Copy link
Contributor

But, when I try to do colcon build, I still have the same issue, am I missing something?

@EleonoreJ with colcon, sometimes it is necessary to "clean" your workspace (e.g. remove the build, install and log directories completely). I'd suggest trying that and rebuilding.

is it compliant with hard real-time requirements?

@EleonoreJ I wont answer this question directly since the purpose of this repository is to demonstrates a simple way to avoid dynamic memory allocations from exceptions. So I guess my answer is: potentially? 😅

Do you know if it violates some Autosar's rules?

@EleonoreJ again, this is beyond the scope of this repo - so the answer again is "potentially". Our good friends at Axivion might be able to help you though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants