Skip to content

Conversation

@Yanfeng-Mi
Copy link

…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

@kgibala
Copy link
Contributor

kgibala commented Dec 10, 2025

Hi @Yanfeng-Mi,

Thank you for your contribution.

We have found several minor issues with your commit, like line length, commit type etc.
Could you please follow the https://github.com/intel/compute-runtime/blob/master/CONTRIBUTING.md guide and correct them?

@Yanfeng-Mi Yanfeng-Mi changed the title Refactor poolbuffer check to fix refcount issue when using clang comp… fix: poolbuffer check refcount issue when using clang compiler Dec 16, 2025
@Yanfeng-Mi Yanfeng-Mi changed the title fix: poolbuffer check refcount issue when using clang compiler fix: poolbuffer check refcount issue when using clang compiler Dec 16, 2025
@Yanfeng-Mi
Copy link
Author

Yanfeng-Mi commented Dec 16, 2025

Hi @Yanfeng-Mi,

Thank you for your contribution.

We have found several minor issues with your commit, like line length, commit type etc. Could you please follow the https://github.com/intel/compute-runtime/blob/master/CONTRIBUTING.md guide and correct them?
done~

@Yanfeng-Mi Yanfeng-Mi closed this Dec 16, 2025
@Yanfeng-Mi Yanfeng-Mi reopened this Dec 16, 2025
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 <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants