Lock the GC mode once something has queried it. All of the GNUstep code that

does run-time detection of whether to use GC calls objc_collecting_enabled()
(sometimes indirectly, via NSGarbageCollector) to see if we're in GC mode.
After any of these calls, it is not safe to switch modes.
main
theraven 15 years ago
parent fe5d1b892a
commit d1199844cb

@ -61,7 +61,7 @@ static int known_abi_count =
}\
} while(0)
static enum objc_gc_mode current_gc_mode = GC_Optional;
PRIVATE enum objc_gc_mode current_gc_mode = GC_Optional;
static BOOL endsWith(const char *string, const char *suffix)
{

@ -531,6 +531,9 @@ static void init(void)
BOOL objc_collecting_enabled(void)
{
// Lock the GC in the current state once it's been queried. This prevents
// the loading of any modules with an incompatible GC mode.
current_gc_mode = isGCEnabled ? GC_Required : GC_None;
return isGCEnabled;
}

@ -54,6 +54,10 @@ enum objc_gc_mode
/**
* The current Objective-C garbage collection mode.
*/
extern enum objc_gc_mode current_gc_mode;
/**
* Have we loaded any code that triggers the ObjC GC support?
*/
extern BOOL isGCEnabled;
/**

Loading…
Cancel
Save