fix: poolbuffer check refcount issue when using clang compiler#860
fix: poolbuffer check refcount issue when using clang compiler#860Yanfeng-Mi wants to merge 1 commit intointel:masterfrom
Conversation
|
Hi @Yanfeng-Mi, Thank you for your contribution. We have found several minor issues with your commit, like line length, commit type etc. |
a1339ee to
ad68471
Compare
|
The issue was traced to a subtle difference in std::unique_ptr's destruction process between Clang (libc++) and GCC (libstdc++). Clang's unique_ptr destructor first nullifies its internal pointer before calling the deleter, meaning that within the managed object's destructor, the owning pointer is already nullptr. In contrast, GCC's unique_ptr directly calls the deleter without first setting the internal pointer to nullptr. This difference caused a specific dependency or interaction within the managed object's destructor to behave incorrectly under GCC because it still saw a non-null owning pointer, leading to unexpected behavior during cleanup. PR is using flag-based system to replace the problematic pointer comparison ref intel#744 Signed-off-by: Mi, Yanfeng <yanfeng.mi@intel.com>
ad68471 to
21b452e
Compare
|
Hi @Yanfeng-Mi, Thank you for the update. Due to the holiday season, dispatch times may be longer than usual. We appreciate your understanding and patience. We will provide updates as soon as your order is dispatched according to our internal process. |
JablonskiMateusz
left a comment
There was a problem hiding this comment.
please check if the patch applies to top branch since logic around buffer pools within Context was changed and the original callstack is not available with latest driver
| const auto *bufferObj = static_cast<const BufferType *>(buffer); | ||
| return bufferObj && bufferObj->isPoolBuffer(); |
There was a problem hiding this comment.
could you cover this at AbstractBuffersPool level (where mainStorage is a part of common interface) instead of at BufferType level (which requires all BufferType interfaces to provide additional API)?
…iler
The issue root-caused to the subtle difference of unique_ptr's destructor between clang and gcc:
Clang (libc++): Calls unique_ptr's destructor, which first clears the internal pointer to nullptr and then calls the deleter on the old pointer value. This means that within the destructor of the managed object, the owning unique_ptr's internal pointer is already nullified.
GCC (libstdc++): The destructor directly calls the deleter on the current pointer without first setting it to nullptr
Fix: using flag-based system to replace the problematic pointer comparison ref #744