ObjFW  Check-in [82cba67e09]

Overview
Comment:Fix theoretically invalid SysBase

This is theoretical, as this is happening in Forbid() and hence nothing
should be able to change it, even after FreeMem(). However, some
debugging tools might break Forbid(), and this commit fixes those.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | amiga-library
Files: files | file ages | folders
SHA3-256: 82cba67e0983e9122213b45ef77600c2c54d674105b8d44269199ac75d6e1bed
User & Date: js on 2020-11-14 19:49:04
Other Links: branch diff | manifest | tags
Context
2020-11-15
02:22
Link against Amiga library if available check-in: 19b5857f27 user: js tags: amiga-library
2020-11-14
19:49
Fix theoretically invalid SysBase check-in: 82cba67e09 user: js tags: amiga-library
19:26
Merge trunk into branch "amiga-library" check-in: 2f8792bc1d user: js tags: amiga-library
Changes

Modified src/amiga-library.m from [2eef08ac58] to [e46fd1fbb1].

292
293
294
295
296
297
298
299

300

301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319

320
321
322
323
324
325
326
327

328
329
330
331
332







333
334
335
336
337
338
339
292
293
294
295
296
297
298

299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328

329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348







-
+

+



















+







-
+





+
+
+
+
+
+
+








	child->dataSeg += DATA_OFFSET;

	return &child->library;
}

static void *
expunge(struct ObjFWBase *base)
expunge(struct ObjFWBase *base, struct ExecBase *sysBase)
{
#define SysBase sysBase
	void *segList;

	if (base->parent != NULL) {
		base->parent->library.lib_Flags |= LIBF_DELEXP;
		return 0;
	}

	if (base->library.lib_OpenCnt > 0) {
		base->library.lib_Flags |= LIBF_DELEXP;
		return 0;
	}

	segList = base->segList;

	Remove(&base->library.lib_Node);
	FreeMem((char *)base - base->library.lib_NegSize,
	    base->library.lib_NegSize + base->library.lib_PosSize);

	return segList;
#undef SysBase
}

static void *__saveds
lib_expunge(void)
{
	OF_M68K_ARG(struct ObjFWBase *, base, a6)

	return expunge(base);
	return expunge(base, SysBase);
}

static void *__saveds
lib_close(void)
{
	/*
	 * SysBase becomes invalid during this function, so we store it in
	 * sysBase and add a define to make the inlines use the right one.
	 */
	struct ExecBase *sysBase = SysBase;
#define SysBase sysBase

	OF_M68K_ARG(struct ObjFWBase *, base, a6)

	if (base->parent != NULL) {
		struct ObjFWBase *parent;

#ifdef OF_AMIGAOS_M68K
		if (base->initialized)
349
350
351
352
353
354
355
356

357
358

359
360
361
362
363
364
365
358
359
360
361
362
363
364

365
366
367
368
369
370
371
372
373
374
375







-
+


+







		    base->library.lib_NegSize + base->library.lib_PosSize);

		base = parent;
	}

	if (--base->library.lib_OpenCnt == 0 &&
	    (base->library.lib_Flags & LIBF_DELEXP))
		return expunge(base);
		return expunge(base, sysBase);

	return NULL;
#undef SysBase
}

static void *
lib_null(void)
{
	return NULL;
}