ObjFW  Diff

Differences From Artifact [99568ccb12]:

  • File src/runtime/autorelease.m — part of check-in [e7f4f80e23] at 2020-01-24 03:03:32 on branch trunk — runtime: Correctly handle AR pool push during pop Getting a pointer and increasing it until we reach the top pointer does not work: Releasing an object can temporarily create new autorelease pools, which can trigger resizing of "objects" using realloc, which can move it to a different address, which will then lead to continuing to iterate on a now invalid pointer. This is now solved by using an index into "objects" instead. Since we're now indexing for the pop, let's use indexes everywhere, as they're more readable anyway. While debugging this, I noticed that the last pool is popped quite frequently, only for a new pool to be pushed immediately again. This resulted in a free followed by a malloc every time. Instead, keep the pool, but let OFThread explicitly say when to free everything. (user: js size: 3222) [more...]

To Artifact [81f19ca445]:

  • File src/runtime/autorelease.m — part of check-in [877616edaf] at 2020-09-27 01:56:24 on branch trunk — Fix compiling for old Apple runtime (user: js size: 3365)

16
17
18
19
20
21
22

23
24





25
26
27
28






29
30
31
32
33
34
35
16
17
18
19
20
21
22
23


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45







+
-
-
+
+
+
+
+




+
+
+
+
+
+







 */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#ifdef OF_OBJFW_RUNTIME
#import "ObjFWRT.h"
#import "private.h"
# import "ObjFWRT.h"
# import "private.h"
#else
# import <objc/runtime.h>
#endif

#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS)
# import "tlskey.h"
#endif

#ifndef OF_OBJFW_RUNTIME
@interface DummyObject
- (void)release;
@end
#endif

#if defined(OF_HAVE_COMPILER_TLS)
static thread_local id *objects = NULL;
static thread_local uintptr_t count = 0;
static thread_local uintptr_t size = 0;
#elif defined(OF_HAVE_THREADS)
static of_tlskey_t objectsKey, countKey, sizeKey;