Skip to content

Commit

Permalink
Fix crash when using directors in Python without limited API
Browse files Browse the repository at this point in the history
Call correct functions when unlocking/destroying a mutex implemented
using Python API: they were accidentally exchanged in 21f1c92 (Make
directors implementation for Python work with limited API, 2019-12-23)
resulting in crashes when using directors and threads together.

Closes swig#2889, swig#3112.
  • Loading branch information
vadz committed Jan 28, 2025
1 parent c67582d commit 892be2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.current
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.4.0 (in progress)
===========================

2025-01-27: StefanBattmer
[Python] #2889 Fix regression when using directors and threads
but not using limited API.

2024-12-07: arbrauns
[Lua] #3083 Fix "unsigned long long" being interpreted as "signed
long long".
Expand Down
4 changes: 2 additions & 2 deletions Lib/python/director_py_mutex.swg
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ namespace Swig {
PyThread_type_lock mutex_;
public:
Mutex() : mutex_(PyThread_allocate_lock()) {}
~Mutex() { PyThread_release_lock(mutex_); }
~Mutex() { PyThread_free_lock(mutex_); }
void lock() { PyThread_acquire_lock(mutex_, WAIT_LOCK); }
void unlock() { PyThread_free_lock(mutex_); }
void unlock() { PyThread_release_lock(mutex_); }
};
}
#endif

0 comments on commit 892be2b

Please sign in to comment.