Fix session use-after-free when UserLoggingFunction is used#28314
Open
Fix session use-after-free when UserLoggingFunction is used#28314
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #28274. Addresses reviewer feedback by also moving
user_logging_manager_(and its raw pointer aliaslogging_manager_) beforeowned_session_logger_andexecution_providers_inInferenceSession's member declaration order.When
SessionOptions::user_logging_functionis set, the session creates a per-sessionuser_logging_manager_and the session logger is created from it. Previously,user_logging_manager_was declared afterexecution_providers_, causing the logging manager to be destroyed before EPs during session teardown — a use-after-free if any EP logs in its destructor.Changes
inference_session.h: Movelogging_manager_anduser_logging_manager_declarations to beforeowned_session_logger_andexecution_providers_, ensuring correct destruction order.inference_session_test.cc: AddSessionLoggerOutlivesEPsWithUserLoggingFunctionregression test that validates the user-logging-function path.Testing
All three
SessionLoggerOutlivesEPs*tests pass locally:Fixes #28234