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
Docker cpputest breaks on #include <unordered_map> #1768
Comments
I've created a minimal example in this repo to troubleshoot this. I am trying from both the docker container and also a native build on my cpu (c++13.2.1). After reading through the suggestions on memory leak I tried adding I've also noticed threads like this, which mention a default constructor. I'm not experienced enough with C++ to know how to implement this. |
What are the first two lines in your test file? The error says "MyFirstTest.cpp:3" which means the file was included on line 3. |
Ah shoot! I didn't notice that submodules cant be viewed on github. I've re-added cpputest-stater and ArduinoFake without the submodule. To your question The only line above includes TestHarness.h note: after added the comment, the failing line is now line 4. |
Can you change these includes to before the TestHarness include ? |
Same error when ArduinoFake is imported before TestHarness. |
Just a quick update that i encountered the same error from the opposite direction by adapting ArduinoFake's example project (using unity) to use cpputest instead |
Good evening, Today I was able to reduce that last to to a minimum reproducible example via cmake and the code sample provided in the last section of the cpputest README. Hopefully you can reproduce it on your machine. |
Hello everyone
@basvodde Do you have any ideas? |
Have you tried building with memory leak detection disabled? |
Hi Ali,
This pull request from Ryan is what showed me how to include libs in the
proper order using cmake.
https://github.com/graial/ArduinoFake-cpputest/pulls?q=is%3Apr+is%3Aclosed
Have a look, give it a try, if still no luck, I'll be able to have a closer
look after Sunday.
I suggest forking the repo and sharing that fork so that others can
reproduce the error.
Cheers
…On Sat, May 11, 2024, 7:54 AM Chad Condon, ***@***.***> wrote:
Have you tried building with memory leak detection disabled?
—
Reply to this email directly, view it on GitHub
<#1768 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKM6M4CM3VEMB43RZWFASR3ZBVM47AVCNFSM6AAAAABARA7DZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBVGM4TCMBRHE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi @graial thanks for your answer. I found an easier solution to reproduce the problem. Open cyber-dojo and click on "enter an existing practice" then enter this code "al5NpW". |
Afternoon Ali,
The containers on that cyber-dojo link seem to freeze when I try to run.
So I can't try to tweak myself, but this is the relevant section of the
manual:
https://cpputest.github.io/manual.html#conflicts-with-operator-new-macros-stl
and here's a code sample you can try:
```
#ifndef MY_MEMORY_LEAK_DETECOTOR_NEW_MACROS_FILE_INCLUDED
#define MY_MEMORY_LEAK_DETECOTOR_NEW_MACROS_FILE_INCLUDED
#include <unordered_map>
#include "CppUTest/MemoryLeakDetectorNewMacros.h"
#endif
```
Which was plucked from this thread
https://groups.google.com/g/cpputest/c/Vfui5TeoXgg
Cheers
…On Sun, May 12, 2024 at 4:27 AM Ali Rostami ***@***.***> wrote:
Hi @graial <https://github.com/graial> thanks for your answer.
I took a look at it, but it didn't help me.
I found an easier solution to reproduce the problem. Open cyber-dojo
<https://cyber-dojo.org/creator/home> and click on "enter an existing
practice" then enter this code "al5NpW".
You can see there, that when #include <unordered_map> is not commented in
the HikerTest file, it gives a compile error.
—
Reply to this email directly, view it on GitHub
<#1768 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKM6M4CCJD2CDNWRRUQNJA3ZBZ5K3AVCNFSM6AAAAABARA7DZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBWGAYTEMBSGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Product Development/R&D
www.sunEtrike.com
|
Unfortunately it didn't help. I also tried to turn off memory leak detection by using this:
But it still gives me compile error. |
I mean at build time by defining |
@ali-rostami The error you get is because of a placement operator new usage in STL. You seem to use the MakefileWorking.mk, which enables the "new macro" for adding memory leak info in line 307. Which means that the macro replacement will be included before the ordered list. As @thetic mentioned, you'll need to disable that. You can do that in the Makefileworker.mk by setting CPPUTEST_USE_MEM_LEAK_DETECTION to N. Then it will set the define that @thetic mentioned. |
Thanks to both of you🙏🙂 |
Greetings, I am encountering what appears to be this issue when trying to include ArduinoFake in a project that uses the docker version of cpputest. provided in cpputest-starter-project
In file included from /usr/local/include/c++/12.2.0/bits/hashtable.h:35, from /usr/local/include/c++/12.2.0/unordered_map:46, from mocks/ArduinoFake/src/ArduinoFake.h:8, from mocks/ArduinoFake/src/Arduino.h:1, from tests/MyFirstTest.cpp:3: /usr/local/include/c++/12.2.0/bits/hashtable_policy.h: In member function 'void std::__detail::_Local_iterator_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, false>::_M_init(const __hash_code_base&)': /usr/local/include/c++/12.2.0/bits/hashtable_policy.h:1495:15: error: expected type-specifier before 'this' 1495 | { ::new(this->_M_h()) __hash_code_base(__base); }
The fix mentioned in the seems like something that cannot be tweaked within the dockerfile. Would I need to do a native build instead?
Many thanks
The text was updated successfully, but these errors were encountered: