Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
1376eb0e
Commit
1376eb0e
authored
Dec 12, 2019
by
Boris Staletic
Committed by
Wenzel Jakob
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Free tstate on python 3.7+ on finalize_interpreter (#2020)
parent
fb910ae9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletions
+13
-1
include/pybind11/detail/internals.h
+13
-1
No files found.
include/pybind11/detail/internals.h
View file @
1376eb0e
...
@@ -25,6 +25,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
...
@@ -25,6 +25,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
# define PYBIND11_TLS_GET_VALUE(key) PyThread_tss_get((key))
# define PYBIND11_TLS_GET_VALUE(key) PyThread_tss_get((key))
# define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_tss_set((key), (value))
# define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_tss_set((key), (value))
# define PYBIND11_TLS_DELETE_VALUE(key) PyThread_tss_set((key), nullptr)
# define PYBIND11_TLS_DELETE_VALUE(key) PyThread_tss_set((key), nullptr)
# define PYBIND11_TLS_FREE(key) PyThread_tss_free(key)
#else
#else
// Usually an int but a long on Cygwin64 with Python 3.x
// Usually an int but a long on Cygwin64 with Python 3.x
# define PYBIND11_TLS_KEY_INIT(var) decltype(PyThread_create_key()) var = 0
# define PYBIND11_TLS_KEY_INIT(var) decltype(PyThread_create_key()) var = 0
...
@@ -43,6 +44,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
...
@@ -43,6 +44,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
# define PYBIND11_TLS_REPLACE_VALUE(key, value) \
# define PYBIND11_TLS_REPLACE_VALUE(key, value) \
PyThread_set_key_value((key), (value))
PyThread_set_key_value((key), (value))
# endif
# endif
# define PYBIND11_TLS_FREE(key) (void)key
#endif
#endif
// Python loads modules by default with dlopen with the RTLD_LOCAL flag; under libc++ and possibly
// Python loads modules by default with dlopen with the RTLD_LOCAL flag; under libc++ and possibly
...
@@ -108,6 +110,16 @@ struct internals {
...
@@ -108,6 +110,16 @@ struct internals {
#if defined(WITH_THREAD)
#if defined(WITH_THREAD)
PYBIND11_TLS_KEY_INIT
(
tstate
);
PYBIND11_TLS_KEY_INIT
(
tstate
);
PyInterpreterState
*
istate
=
nullptr
;
PyInterpreterState
*
istate
=
nullptr
;
~
internals
()
{
// This destructor is called *after* Py_Finalize() in finalize_interpreter().
// That *SHOULD BE* fine. The following details what happens whe PyThread_tss_free is called.
// PYBIND11_TLS_FREE is PyThread_tss_free on python 3.7+. On older python, it does nothing.
// PyThread_tss_free calls PyThread_tss_delete and PyMem_RawFree.
// PyThread_tss_delete just calls TlsFree (on Windows) or pthread_key_delete (on *NIX). Neither
// of those have anything to do with CPython internals.
// PyMem_RawFree *requires* that the `tstate` be allocated with the CPython allocator.
PYBIND11_TLS_FREE
(
tstate
);
}
#endif
#endif
};
};
...
@@ -138,7 +150,7 @@ struct type_info {
...
@@ -138,7 +150,7 @@ struct type_info {
};
};
/// Tracks the `internals` and `type_info` ABI version independent of the main library version
/// Tracks the `internals` and `type_info` ABI version independent of the main library version
#define PYBIND11_INTERNALS_VERSION
3
#define PYBIND11_INTERNALS_VERSION
4
/// On MSVC, debug and release builds are not ABI-compatible!
/// On MSVC, debug and release builds are not ABI-compatible!
#if defined(_MSC_VER) && defined(_DEBUG)
#if defined(_MSC_VER) && defined(_DEBUG)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment