mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Protect bfd symbol lookup for thread safety
This commit is contained in:
parent
21a48f6136
commit
6011b3c528
1 changed files with 8 additions and 5 deletions
|
@ -114,6 +114,9 @@ static NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler = 0;
|
|||
- (GSStackTrace*) _callStack;
|
||||
@end
|
||||
|
||||
#if defined(_WIN32) || defined(USE_BFD)
|
||||
static gs_mutex_t traceLock;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(USE_BFD)
|
||||
|
@ -402,7 +405,7 @@ struct SearchAddressStruct
|
|||
GSFunctionInfo *theInfo;
|
||||
};
|
||||
|
||||
static void find_address (bfd *abfd, asection *section,
|
||||
static void find_address(bfd *abfd, asection *section,
|
||||
struct SearchAddressStruct *info)
|
||||
{
|
||||
bfd_vma address;
|
||||
|
@ -484,8 +487,10 @@ static void find_address (bfd *abfd, asection *section,
|
|||
struct SearchAddressStruct searchInfo =
|
||||
{ address, self, _symbols, nil };
|
||||
|
||||
bfd_map_over_sections (_abfd,
|
||||
GS_MUTEX_LOCK(traceLock);
|
||||
bfd_map_over_sections(_abfd,
|
||||
(void (*) (bfd *, asection *, void *)) find_address, &searchInfo);
|
||||
GS_MUTEX_UNLOCK(traceLock);
|
||||
return searchInfo.theInfo;
|
||||
}
|
||||
|
||||
|
@ -615,13 +620,11 @@ static SymInitializeType initSym = 0;
|
|||
static SymSetOptionsType optSym = 0;
|
||||
static SymFromAddrType fromSym = 0;
|
||||
static HANDLE hProcess = 0;
|
||||
static gs_mutex_t traceLock;
|
||||
#define MAXFRAMES 62 /* Limitation of windows-xp */
|
||||
#else
|
||||
#define MAXFRAMES 128 /* 1KB buffer on 64bit machine */
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(HAVE_BUILTIN_EXTRACT_RETURN_ADDRESS)
|
||||
# define __builtin_extract_return_address(X) X
|
||||
#endif
|
||||
|
@ -1111,7 +1114,7 @@ GSPrivateReturnAddresses(NSUInteger **returns)
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
#if defined(_WIN32) && !defined(USE_BFD)
|
||||
#if defined(_WIN32) || defined(USE_BFD)
|
||||
GS_MUTEX_INIT_RECURSIVE(traceLock);
|
||||
#endif
|
||||
#if defined(USE_BFD)
|
||||
|
|
Loading…
Reference in a new issue