nasa / trick

Trick Simulation Environment. Trick provides a common set of simulation capabilities and utilities to build simulations automatically.
Other
34 stars 19 forks source link

Sim compile errors on Ubuntu 22 and Oracle Linux 9.2 using gcc 11 #1556

Open dandexter opened 1 year ago

dandexter commented 1 year ago

I'm getting simulation compile errors on Ubuntu 22 LTS and Oracle Linux 9.2 and I think it is related to gcc 11.

I'm using the latest Trick from the repo on a fresh install of both Ubuntu 22 LTS and OL 9.2 using the Trick installation instructions. Also I am using the latest TrickHLA code from master.

The simulation does compile and link even with these errors. I think this is during ICG.

I show the simulation errors for both Ubuntu and OL below:

==================================== Ubuntu 22.04.3 LTS gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

In file included from /home/ddexter/projects/TrickHLA/sims/SpaceFOM/SIM_Roles_Test/S_source.hh:11: In file included from /usr/include/c++/11/iostream:39: In file included from /usr/include/c++/11/ostream:38: In file included from /usr/include/c++/11/ios:42: In file included from /usr/include/c++/11/bits/ios_base.h:41: In file included from /usr/include/c++/11/bits/locale_classes.h:40: In file included from /usr/include/c++/11/string:55: In file included from /usr/include/c++/11/bits/basic_string.h:6608: In file included from /usr/include/c++/11/ext/string_conversions.h:41: In file included from /usr/include/c++/11/cstdlib:75: /usr/include/stdlib.h:566:5: error: 'malloc' attribute takes no arguments __attr_dealloc_free; ^ /usr/include/x86_64-linux-gnu/sys/cdefs.h:691:30: note: expanded from macro '__attr_dealloc_free'

define attr_dealloc_free attr_dealloc (__builtin_free, 1)

                         ^

/usr/include/x86_64-linux-gnu/sys/cdefs.h:690:21: note: expanded from macro 'attr_dealloc' attribute ((malloc (dealloc, argno))) ^ In file included from /home/ddexter/projects/TrickHLA/sims/SpaceFOM/SIM_Roles_Test/S_source.hh:11: In file included from /usr/include/c++/11/iostream:39: In file included from /usr/include/c++/11/ostream:38: In file included from /usr/include/c++/11/ios:42: In file included from /usr/include/c++/11/bits/ios_base.h:41: In file included from /usr/include/c++/11/bits/locale_classes.h:40: In file included from /usr/include/c++/11/string:55: In file included from /usr/include/c++/11/bits/basic_string.h:6608: In file included from /usr/include/c++/11/ext/string_conversions.h:41: In file included from /usr/include/c++/11/cstdlib:75: /usr/include/stdlib.h:570:14: error: 'malloc' attribute takes no arguments THROW attr_dealloc (reallocarray, 1); ^ /usr/include/x86_64-linux-gnu/sys/cdefs.h:690:21: note: expanded from macro 'attr_dealloc' attribute ((malloc (dealloc, argno))) ^

(not showing all the errors)

======================================================= Red Hat Enterprise Linux release 9.2 (Plow) gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4.3.0.1)

In file included from /home/ddexter/projects/TrickHLA/sims/SpaceFOM/SIM_Roles_Test/S_source.hh:11: In file included from /usr/include/c++/11/iostream:39: In file included from /usr/include/c++/11/ostream:38: In file included from /usr/include/c++/11/ios:38: In file included from /usr/include/c++/11/iosfwd:40: In file included from /usr/include/c++/11/bits/postypes.h:40: In file included from /usr/include/c++/11/cwchar:44: /usr/include/wchar.h:155:24: error: 'malloc' attribute takes no arguments __attribute_malloc attr_dealloc_free; ^ /usr/include/sys/cdefs.h:683:30: note: expanded from macro '__attr_dealloc_free'

define attr_dealloc_free attr_dealloc (__builtin_free, 1)

                         ^

/usr/include/sys/cdefs.h:682:21: note: expanded from macro 'attr_dealloc' attribute ((malloc (dealloc, argno))) ^ In file included from /home/ddexter/projects/TrickHLA/sims/SpaceFOM/SIM_Roles_Test/S_source.hh:11: In file included from /usr/include/c++/11/iostream:39: In file included from /usr/include/c++/11/ostream:38: In file included from /usr/include/c++/11/ios:42: In file included from /usr/include/c++/11/bits/ios_base.h:41: In file included from /usr/include/c++/11/bits/locale_classes.h:40: In file included from /usr/include/c++/11/string:55: In file included from /usr/include/c++/11/bits/basic_string.h:6608: In file included from /usr/include/c++/11/ext/string_conversions.h:41: In file included from /usr/include/c++/11/cstdlib:75: /usr/include/stdlib.h:565:5: error: 'malloc' attribute takes no arguments attr_dealloc_free; ^ /usr/include/sys/cdefs.h:683:30: note: expanded from macro '__attr_dealloc_free'

define attr_dealloc_free attr_dealloc (__builtin_free, 1)

                         ^

/usr/include/sys/cdefs.h:682:21: note: expanded from macro '__attr_dealloc' attribute ((malloc (dealloc, argno))) ^ (not showing all the errors)

jdeans289 commented 1 year ago

Yeah I agree that you probably shouldn't trust this in production even though it links, the io_src attributes are likely mangled. I'll investigate this and see if we can come up with a solution.

keithvetter commented 1 year ago

I looked into this as part of this issue: https://github.com/nasa/trick/issues/1553

Here is my last comment on #1553:

After much reading (and talking with ChatGPT!) I think the fix for the malloc error is in LLVM/clang's court. I think we'll just have to wait for a fix and live with the non-fatal error until LLVM/clang accomodate gcc 11's malloc attribute with arguments.

I see no workaround. The last comment I gave didn't work for S_source.hh.

Here is a post on the gcc11 change: https://developers.redhat.com/blog/2021/04/30/detecting-memory-management-bugs-with-gcc-11-part-1-understanding-dynamic-allocation

Here are two open LLVM issues to fix it: https://github.com/llvm/llvm-project/issues/51607 https://github.com/llvm/llvm-project/issues/53152