-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Some additional changes I needed for gcc to build the source #17655
base: development
Are you sure you want to change the base?
Conversation
Currently it is more a subject for discussion I guess, so I'd like to collect some feedback. |
bd003a3
to
c19d7cd
Compare
Started AR, but awaiting response from @o3de/sig-build before reviewing. |
c19d7cd
to
8247f1a
Compare
@@ -2015,7 +2015,9 @@ namespace AZ | |||
} | |||
else | |||
{ | |||
AZ_PUSH_DISABLE_WARNING_GCC(-Wdangling-pointer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This statement looks wrong, it should be
AZ_PUSH_DISABLE_WARNING_GCC(-Wdangling-pointer); | |
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); |
This will produce an error like:
missing option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
is that why there is an additional -Wno-error=pragmas
below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed that.
@@ -73,6 +74,15 @@ ly_append_configurations_options( | |||
-Wno-switch | |||
-Wno-uninitialized | |||
-Wno-unused-result | |||
-Wno-dangling-pointer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In file included from /media/slapin/data/o3de-projects/NewspaperDeliveryGame/build/linux/o3de/Code/Framework/AzCore/CMakeFiles/AzCore.dir/Unity/unity_15_cxx.cxx:15:
/media/slapin/data/o3de/Code/Framework/AzCore/AzCore/Metrics/EventLoggerReflectUtils.cpp: In function ‘AZ::Metrics::Script::ReflectRecordEvent(AZ::BehaviorContext&)::<lambda(AZ::Metrics::EventLoggerId, AZ::Metrics::EventPhaseNamespace::EventPhase, AZ::Metrics::Script::ScriptEventArgs, AZ::Metrics::IEventLoggerFactory*)>’:
/media/slapin/data/o3de/Code/Framework/AzCore/AzCore/Metrics/EventLoggerReflectUtils.cpp:465:66: note: unnamed temporary defined here
465 | asyncArgs.m_id = eventPhaseArgs.m_id.value_or(AZStd::string_view{});
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
No, that is still needed
-Wno-error=unused-but-set-variable | ||
-Wno-error=unused-variable | ||
-Wno-error=subobject-linkage | ||
-Wno-error=pragmas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldnt be needed with that warning disable statement above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed -Wno-error=pragmas
8247f1a
to
865aaab
Compare
Please explain Jenkins errors, these do not look like related... |
It looks like the pdb files were corrupted. I've seen this happen in a couple of recent builds, so the corruption is mostl likely caused by the intermediate artifacts that gets cached and pushed to other intermediate builds. You can restart the build with a rebuild all, but that cache will need to be cleaned up either way. |
Ah, thanks, so these are beyond what I can do and not related to the changes. |
With this PR and build with gcc-13 using script
I confirm Paper Kid game builds and run with Editor working. I run AssetProcessorBatch as AssetProcessor is annoying af, otherwise everything seems to be working. |
865aaab
to
a913104
Compare
a913104
to
18f1a08
Compare
-Wno-error=return-local-addr | ||
-Wno-error=nonnull | ||
-Wno-error=free-nonheap-object | ||
-Wno-error=use-after-free |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These warnings actually are important and useful.
Returning a pointer to a local address or using a variable after free shouldn't be ignored, but the code in question should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I can handle the volume, but I will try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/media/slapin/data/o3de/Code/Editor/Util/ImageTIF.cpp: In static member function ‘static const char* CImageTIF::GetPreset(const QString&)’:
/media/slapin/data/o3de/Code/Editor/Util/ImageTIF.cpp:498:1: error: function may return address of local variable [-Werror=return-local-addr]
498 | }
| ^
/media/slapin/data/o3de/Code/Editor/Util/ImageTIF.cpp:475:19: note: declared here
475 | AZStd::string strReturn;
| ^~~~~~~~~
The function returns c_str() from local string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't look good :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is actually a legitimate bug that shouldn't be suppressed.
It looks like there isn't any code which calls the GetPreset function which returns a local const char*
.
Therefore we can just delete the entire function itself to fix the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of stuff like
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘constexpr ForwardIterator AZStd::Internal::uninitialized_move(InputIterator, InputIterator, ForwardIterator, bool) [with InputIterator = AZ::Component**; ForwardIterator = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:526:29,
inlined from ‘ForwardIt AZStd::uninitialized_move(InputIt, InputIt, ForwardIt) [with InputIt = AZ::Component**; ForwardIt = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:555:51,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_iter(const_iterator, Iterator, Iterator) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1125:56,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_impl(const_iterator, const Iterator&, const Iterator&, const std::false_type&) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1067:31,
inlined from ‘T* AZStd::vector<T, Allocator>::insert(const_iterator, InputIterator, InputIterator) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:787:31,
inlined from ‘void AZStd::vector<T, Allocator>::assign_iter(const InputIterator&, const InputIterator&, const std::false_type&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1245:19,
inlined from ‘void AZStd::vector<T, Allocator>::assign(const InputIterator&, const InputIterator&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:595:24,
inlined from ‘static std::unique_ptr<QMimeData> AzToolsFramework::ComponentMimeData::Create(AZStd::span<AZ::Component* const>)’ at /media/slapin/data/o3de/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ComponentMimeData.cpp:129:46:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: error: argument 2 null where non-null expected [-Werror=nonnull]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: note: in a call to built-in function ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘constexpr ForwardIterator AZStd::Internal::uninitialized_move(InputIterator, InputIterator, ForwardIterator, bool) [with InputIterator = AZ::Component**; ForwardIterator = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:526:29,
inlined from ‘ForwardIt AZStd::uninitialized_move(InputIt, InputIt, ForwardIt) [with InputIt = AZ::Component**; ForwardIt = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:555:51,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_iter(const_iterator, Iterator, Iterator) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1147:64,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_impl(const_iterator, const Iterator&, const Iterator&, const std::false_type&) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1067:31,
inlined from ‘T* AZStd::vector<T, Allocator>::insert(const_iterator, InputIterator, InputIterator) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:787:31,
inlined from ‘void AZStd::vector<T, Allocator>::assign_iter(const InputIterator&, const InputIterator&, const std::false_type&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1245:19,
inlined from ‘void AZStd::vector<T, Allocator>::assign(const InputIterator&, const InputIterator&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:595:24,
inlined from ‘static std::unique_ptr<QMimeData> AzToolsFramework::ComponentMimeData::Create(AZStd::span<AZ::Component* const>)’ at /media/slapin/data/o3de/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ComponentMimeData.cpp:129:46:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: error: argument 2 null where non-null expected [-Werror=nonnull]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: note: in a call to built-in function ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘constexpr ForwardIterator AZStd::Internal::copy(InputIterator, InputIterator, ForwardIterator, bool) [with InputIterator = AZ::Component* const*; ForwardIterator = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:256:29,
inlined from ‘constexpr OutputIterator AZStd::copy(InputIterator, InputIterator, OutputIterator) [with InputIterator = AZ::Component* const*; OutputIterator = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:391:30,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_iter(const_iterator, Iterator, Iterator) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1162:32,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_impl(const_iterator, const Iterator&, const Iterator&, const std::false_type&) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1067:31,
inlined from ‘T* AZStd::vector<T, Allocator>::insert(const_iterator, InputIterator, InputIterator) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:787:31,
inlined from ‘void AZStd::vector<T, Allocator>::assign_iter(const InputIterator&, const InputIterator&, const std::false_type&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1245:19,
inlined from ‘void AZStd::vector<T, Allocator>::assign(const InputIterator&, const InputIterator&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:595:24,
inlined from ‘static std::unique_ptr<QMimeData> AzToolsFramework::ComponentMimeData::Create(AZStd::span<AZ::Component* const>)’ at /media/slapin/data/o3de/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ComponentMimeData.cpp:129:46:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: error: argument 1 null where non-null expected [-Werror=nonnull]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: note: in a call to built-in function ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’
In function ‘void* memmove(void*, const void*, size_t)’,
inlined from ‘constexpr BidirectionalIterator2 AZStd::Internal::move_backward(BidirectionalIterator1, BidirectionalIterator1, BidirectionalIterator2, bool) [with BidirectionalIterator1 = AZ::Component**; BidirectionalIterator2 = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:485:30,
inlined from ‘BidirectionalIterator2 AZStd::move_backward(BidirectionalIterator1, BidirectionalIterator1, BidirectionalIterator2) [with BidirectionalIterator1 = AZ::Component**; BidirectionalIterator2 = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:567:46,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_iter(const_iterator, Iterator, Iterator) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1177:41,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_impl(const_iterator, const Iterator&, const Iterator&, const std::false_type&) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1067:31,
inlined from ‘T* AZStd::vector<T, Allocator>::insert(const_iterator, InputIterator, InputIterator) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:787:31,
inlined from ‘void AZStd::vector<T, Allocator>::assign_iter(const InputIterator&, const InputIterator&, const std::false_type&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1245:19,
inlined from ‘void AZStd::vector<T, Allocator>::assign(const InputIterator&, const InputIterator&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:595:24,
inlined from ‘static std::unique_ptr<QMimeData> AzToolsFramework::ComponentMimeData::Create(AZStd::span<AZ::Component* const>)’ at /media/slapin/data/o3de/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ComponentMimeData.cpp:129:46:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:36:34: error: argument 2 null where non-null expected [-Werror=nonnull]
36 | return __builtin___memmove_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
37 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:36:34: note: in a call to built-in function ‘void* __builtin_memmove(void*, const void*, long unsigned int)’
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘constexpr ForwardIterator AZStd::Internal::copy(InputIterator, InputIterator, ForwardIterator, bool) [with InputIterator = AZ::Component* const*; ForwardIterator = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:256:29,
inlined from ‘constexpr OutputIterator AZStd::copy(InputIterator, InputIterator, OutputIterator) [with InputIterator = AZ::Component* const*; OutputIterator = AZ::Component**]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/createdestroy.h:391:30,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_iter(const_iterator, Iterator, Iterator) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1180:32,
inlined from ‘T* AZStd::vector<T, Allocator>::insert_impl(const_iterator, const Iterator&, const Iterator&, const std::false_type&) [with Iterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1067:31,
inlined from ‘T* AZStd::vector<T, Allocator>::insert(const_iterator, InputIterator, InputIterator) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:787:31,
inlined from ‘void AZStd::vector<T, Allocator>::assign_iter(const InputIterator&, const InputIterator&, const std::false_type&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:1245:19,
inlined from ‘void AZStd::vector<T, Allocator>::assign(const InputIterator&, const InputIterator&) [with InputIterator = AZ::Component* const*; T = AZ::Component*; Allocator = AZStd::allocator]’ at /media/slapin/data/o3de/Code/Framework/AzCore/./AzCore/std/containers/vector.h:595:24,
inlined from ‘static std::unique_ptr<QMimeData> AzToolsFramework::ComponentMimeData::Create(AZStd::span<AZ::Component* const>)’ at /media/slapin/data/o3de/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ComponentMimeData.cpp:129:46:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: error: argument 1 null where non-null expected [-Werror=nonnull]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
30 | __glibc_objsize0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
looks like memcpy() arguments problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used static_cast<uint8_t *>(ptr) with std::launder, might work but I'm not sure yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed another set in AZStd::vector but still lots of stuff in other parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mitigated all -Wnonnull things, hope these will be much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
18f1a08
to
81a7b8e
Compare
81a7b8e
to
f831b76
Compare
@@ -132,7 +132,7 @@ namespace AZ | |||
|
|||
bool DirectionalLightComponentConfig::IsEsmDisabled() const | |||
{ | |||
return !m_shadowEnabled || (m_shadowFilterMethod != ShadowFilterMethod::Esm && m_shadowFilterMethod != ShadowFilterMethod::EsmPcf); | |||
return !m_shadowEnabled || !(m_shadowFilterMethod == ShadowFilterMethod::Esm || m_shadowFilterMethod == ShadowFilterMethod::EsmPcf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good ol' De Morgan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is more correct from compiler point of view, need to check which error that was and it was not related to De Morgan per se.
-Wno-error=unused-variable | ||
-Wno-error=subobject-linkage | ||
-Wno-error=nonnull | ||
-Wno-error=free-nonheap-object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
free non-heap
does this really happen or it's a false positive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it happens a lot because of templates freeing stuff not being allocated (having various weird offsets and not page aligned) so I guess some weird magic happens in O3DE which -Wfree-nonheap-object do not understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about -Wfree-nonheap-object:
In destructor ‘_i_reference_target<Counter>::~_i_reference_target() [with Counter = int]’,
inlined from ‘void _i_reference_target<Counter>::Release() [with Counter = int]’ at /media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:335:13,
inlined from ‘_smart_ptr<_I>::~_smart_ptr() [with _I = CUiAnimViewKeyUIControls]’ at /media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:67:23,
inlined from ‘constexpr void std::_Destroy(_Tp*) [with _Tp = _smart_ptr<CUiAnimViewKeyUIControls>]’ at /usr/include/c++/13/bits/stl_construct.h:151:22,
inlined from ‘static void std::_Destroy_aux<<anonymous> >::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = _smart_ptr<CUiAnimViewKeyUIControls>*; bool <anonymous> = false]’ at /usr/include/c++/13/bits/stl_construct.h:163:19,
inlined from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = _smart_ptr<CUiAnimViewKeyUIControls>*]’ at /usr/include/c++/13/bits/stl_construct.h:196:11,
inlined from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator, allocator<_T2>&) [with _ForwardIterator = _smart_ptr<CUiAnimViewKeyUIControls>*; _Tp = _smart_ptr<CUiAnimViewKeyUIControls>]’ at /usr/include/c++/13/bits/alloc_traits.h:947:15,
inlined from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = _smart_ptr<CUiAnimViewKeyUIControls>; _Alloc = std::allocator<_smart_ptr<CUiAnimViewKeyUIControls> >]’ at /usr/include/c++/13/bits/stl_vector.h:732:15,
inlined from ‘virtual CUiAnimViewKeyPropertiesDlg::~CUiAnimViewKeyPropertiesDlg()’ at /media/slapin/data/o3de/Gems/LyShine/Code/Editor/Animation/UiAnimViewKeyPropertiesDlg.h:147:7,
inlined from ‘virtual CUiAnimViewKeyPropertiesDlg::~CUiAnimViewKeyPropertiesDlg()’ at /media/slapin/data/o3de/Gems/LyShine/Code/Editor/Animation/UiAnimViewKeyPropertiesDlg.h:147:7:
/media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:324:5: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘*(CUiAnimViewKeyUIControls**)((char*)__first)’ with nonzero offset 16 [-Werror=free-nonheap-object]
324 | }
| ^
In destructor ‘_i_reference_target<Counter>::~_i_reference_target() [with Counter = int]’,
inlined from ‘void _i_reference_target<Counter>::Release() [with Counter = int]’ at /media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:335:13,
inlined from ‘_smart_ptr<_I>::~_smart_ptr() [with _I = CUiAnimViewKeyUIControls]’ at /media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:67:23,
inlined from ‘constexpr void std::_Destroy(_Tp*) [with _Tp = _smart_ptr<CUiAnimViewKeyUIControls>]’ at /usr/include/c++/13/bits/stl_construct.h:151:22,
inlined from ‘static void std::_Destroy_aux<<anonymous> >::__destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = _smart_ptr<CUiAnimViewKeyUIControls>*; bool <anonymous> = false]’ at /usr/include/c++/13/bits/stl_construct.h:163:19,
inlined from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = _smart_ptr<CUiAnimViewKeyUIControls>*]’ at /usr/include/c++/13/bits/stl_construct.h:196:11,
inlined from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator, allocator<_T2>&) [with _ForwardIterator = _smart_ptr<CUiAnimViewKeyUIControls>*; _Tp = _smart_ptr<CUiAnimViewKeyUIControls>]’ at /usr/include/c++/13/bits/alloc_traits.h:947:15,
inlined from ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(iterator, _Args&& ...) [with _Args = {_smart_ptr<CUiAnimViewKeyUIControls>}; _Tp = _smart_ptr<CUiAnimViewKeyUIControls>; _Alloc = std::allocator<_smart_ptr<CUiAnimViewKeyUIControls> >]’ at /usr/include/c++/13/bits/vector.tcc:517:15:
/media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:324:5: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘*(CUiAnimViewKeyUIControls**)((char*)__first)’ with nonzero offset 16 [-Werror=free-nonheap-object]
324 | }
| ^
In destructor ‘_i_reference_target<Counter>::~_i_reference_target() [with Counter = int]’,
inlined from ‘void _i_reference_target<Counter>::Release() [with Counter = int]’ at /media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:335:13,
inlined from ‘_smart_ptr<_I>::~_smart_ptr() [with _I = CUiAnimViewKeyUIControls]’ at /media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:67:23,
inlined from ‘CUiAnimViewKeyPropertiesDlg::CUiAnimViewKeyPropertiesDlg(QWidget*)’ at /media/slapin/data/o3de/Gems/LyShine/Code/Editor/Animation/UiAnimViewKeyPropertiesDlg.cpp:89:28:
/media/slapin/data/o3de/Code/Legacy/CryCommon/./smartptr.h:324:5: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘<unknown>’ with nonzero offset 16 [-Werror=free-nonheap-object]
324 | }
| ^
In file included from /media/slapin/data/o3de-projects/pong/build/linux/External/LyShine-dae488a6/Code/CMakeFiles/LyShine.Tools.Static.dir/Unity/unity_14_cxx.cxx:7:
/media/slapin/data/o3de/Gems/LyShine/Code/Editor/Animation/UiAnimViewKeyPropertiesDlg.cpp: In constructor ‘CUiAnimViewKeyPropertiesDlg::CUiAnimViewKeyPropertiesDlg(QWidget*)’:
/media/slapin/data/o3de/Gems/LyShine/Code/Editor/Animation/UiAnimViewKeyPropertiesDlg.cpp:87:65: note: returned from ‘void* operator new(std::size_t)’
87 | CUiAnimViewTrackEventKeyUIControls* trackEventControl = new CUiAnimViewTrackEventKeyUIControls;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see how the CUiAnimViewKeyUIControls
class needs to be derived from QObject nor inherit QObject in its class. Might be best to remove that and see if the alignment cleans up - all other ref counted _smart_ptr objects are single-inheritors with no offset... ?
one issue is I can't seem to repro these, on clang16 or clang14 with asan / fortify. So I can't experiment with different options to see if it can be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried removing the QObject inherit and Q_OBJECT in its class def from CUiAnimViewKeyUIControls and the track view seems to work just fine and show those key ui controls without issue, I think it was an oversight. Perhaps removing it will clear the issue for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, indeed it fixed the issue with -Wfree-nonheap-object, Thanks a lot!
f831b76
to
3dad6e4
Compare
AZ_PUSH_DISABLE_WARNING_GCC("-Wuse-after-free"); | ||
AZ_MEMORY_PROFILE(ProfileReallocation(oldPtr, newPtr, allocatedSize, 1)); | ||
AZ_POP_DISABLE_WARNING_GCC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning suppression shouldn't be needed any longer here now that the pointer has been "laundered".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
d00ae4b
to
9b5e0a8
Compare
About dangling pointers -Wdangling-pointer
|
I see, so gcc-13 I use has false-positives about -Wdangling-pointer so these are better be disabled using pragmas. |
9b5e0a8
to
a0e0cd7
Compare
Mitigated -Wdangling-pointer errors using pragmas for easier review. |
a0e0cd7
to
5e4324d
Compare
This is a legitimate error that will cause crashes, FWIW. AZStd::string::format returns a temporary object, and string_view does not capture the acutal memory returned. I searched the code for additional instances of this, and did not find any. |
The similar thing is here. I tried replacing AZStd::string_view with AZStd::string but it did not work. I wonder what produce dangling-pointer here. |
The The dangling pointer is caused by the temporary The fix in this case is to only get a reference to the AZStd::string from the optional if it the optional has a value. i.e if (eventPhaseArgs.m_id.has_value())
{
asyncArgs.m_id = eventPhaseArgs.m_id.value();
} That makes sure the string_view only points to |
auto tmp = eventPhaseArgs.m_id.value_or(AZStd::string_view{}); | ||
asyncArgs.m_id = tmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be fixed by checking if the optional has a value before assigning it to the AsyncArgs
class ID string_view
member
auto tmp = eventPhaseArgs.m_id.value_or(AZStd::string_view{}); | |
asyncArgs.m_id = tmp; | |
if (eventPhaseArgs.m_id.has_value()) | |
{ | |
asyncArgs.m_id = eventPhaseArgs.m_id.value(); | |
} |
@@ -594,18 +594,22 @@ namespace Audio | |||
// warn if there is activity on an object being cleared | |||
if (!m_cActiveEvents.empty()) | |||
{ | |||
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to GetEventIDs, should remove the .c_str()
call and assign the result to an AZStd::string.
const AZStd::string sEventString = GetEventIDs("; ");
} | ||
|
||
if (!m_cTriggers.empty()) | ||
{ | ||
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to GetTriggerNames, should remove the .c_str()
call and assign the result to an AZStd::string.
const AZStd::string sTriggerString = GetTriggerNames("; ", pDebugNameStore);
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | ||
for (auto& it = ++ m_settingsMap.begin(); it != m_settingsMap.end(); ++it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The temporary that is being returned from m_settingsMap.begin()
iterator is being assigned to a reference.
This code should just use plain auto
without the ampersand.
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | |
for (auto& it = ++ m_settingsMap.begin(); it != m_settingsMap.end(); ++it) | |
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | |
for (auto it = ++ m_settingsMap.begin(); it != m_settingsMap.end(); ++it) |
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | ||
AzFramework::StringFunc::Append(bufferArg, type.data()); | ||
AZ_POP_DISABLE_WARNING_GCC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line doesn't produce a dangling refefence.
It is actually the call to FetchPythonType above.
That function returns an AZStd::string. So the variable it is being assigned to should be an AZStd::string
AZStd::string_view type = FetchPythonType(*behaviorMethod.GetArgument(argIndex))
AZStd::string_view type = FetchPythonType(*behaviorProperty.m_setter->GetArgument(1)); | ||
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | ||
AzFramework::StringFunc::Append(buffer, type.data()); | ||
AZ_POP_DISABLE_WARNING_GCC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeat: The assignment to the AZStd::string_view type
variable above should be changed to be of type AZStd::string
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | ||
AZStd::string_view type = FetchPythonType(*behaviorProperty.m_getter->GetResult()); | ||
AzFramework::StringFunc::Append(buffer, "->"); | ||
AzFramework::StringFunc::Append(buffer, type.data()); | ||
AZ_POP_DISABLE_WARNING_GCC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeat: The assignment to the AZStd::string_view type
variable should be changed to be of type AZStd::string
as that is causing the dangling reference.
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | ||
param.m_value = &const_cast<Type&>(result); | ||
AZ_POP_DISABLE_WARNING_GCC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this dangling pointer can be fixed, first getting the address of the result
variable (which in this case is guaranteed to not be a pointer type because this code is in the else block of an if constexpr
statement).
Next that address can have it's constness casted of it.
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | |
param.m_value = &const_cast<Type&>(result); | |
AZ_POP_DISABLE_WARNING_GCC; | |
AZ_PUSH_DISABLE_WARNING_GCC("-Wdangling-pointer"); | |
param.m_value = const_cast<Type*>(&result); | |
AZ_POP_DISABLE_WARNING_GCC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well
param.m_value = const_cast<Type*>(&result);
still ends up as address of local variable :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything else was was fixed properly, thanks!
5e4324d
to
b53af8a
Compare
Signed-off-by: Sergey Lapin <[email protected]>
b53af8a
to
fff1daf
Compare
What does this PR do?
This PR adds changes which are required to produce engine/project build using gcc.
I tested using gcc-11.
Please describe your PR. For a bug fix, what was the old behavior, what is the new behavior?
Lots of various kinds of errors regarding c++ stuff.
Please add links to any issues, RFCs or other items that are relevant to this PR.
How was this PR tested?
Just built on my host ubuntu 22.04 system.
Please describe any testing performed.
Just built and run Editor.
Today, on March, 31 I tried building Paper Kid demo and it works perfectly fine, with editor and game itself,
I used AssetProcessorBatch to pre-process assets.