Fix error when destructing a static std::unique_ptr<cppflow::model>#132
Closed
ihowell wants to merge 1 commit intoserizba:masterfrom
Closed
Fix error when destructing a static std::unique_ptr<cppflow::model>#132ihowell wants to merge 1 commit intoserizba:masterfrom
ihowell wants to merge 1 commit intoserizba:masterfrom
Conversation
When creating a static version of a reference to a `cppflow::model`, there becomes an error when destructing, due to the `context::get_status()` method using a `thread_local` status. While this is done normally for performance gains and is fine in most places. However, when the program is exiting, it first destructs `thread_local` objects and then `static` ones. This leads to `local_tf_status` containing a `nullptr` instead of a pointer to a `TF_Status` object. Therefore, `TF_DeleteSession(sess, status)` fails because it access `*status`. The simplest fix is to not re-use this status object in the destructor of the session and instead make a new, non-`thread_local` status instead.
Closed
3326662 to
c98a475
Compare
Owner
Contributor
|
@serizba Do you mind me having a PR to fix, i.e. adding a per model TF_Status? The global status will be used for eager ops only. There were so many people trying to build cppflow into a dll and having the deinitialuzation order fiasco. |
Owner
|
@ljn917 Yeah sure! This way we'll fix all related issues. Thanks! |
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.
Fixes #131
When creating a static version of a reference to a
cppflow::model,there becomes an error when destructing, due to the
context::get_status()method using athread_localstatus. Whilethis is done normally for performance gains and is fine in most
places. However, when the program is exiting, it first destructs
thread_localobjects and then
staticones. This leads tolocal_tf_statuscontaining a
nullptrinstead of a pointer to aTF_Statusobject. Therefore,
TF_DeleteSession(sess, status)fails because itaccess
*status. The simplest fix is to not re-use this status objectin the destructor of the session and instead make a new,
non-
thread_localstatus instead.