fix `ffi/unsafe/nsalloc'

Using `call-as-atomic' isn't right, because that allows an escape
via `call-as-nonatomic'. Assuming that `call-as-nonatomic' isn't
used, it seems like `call-as-atomic' should be ok, anyway, but
somehow its leads to unbalanced `end-atomic' calls.
This commit is contained in:
Matthew Flatt 2012-08-28 18:44:15 -06:00
parent 003613395d
commit d953bc27ba
2 changed files with 14 additions and 4 deletions

View File

@ -18,11 +18,13 @@
(define (call-with-autorelease thunk)
(unless NSAutoreleasePool
(error 'NSAutoreleasePool "not available"))
(call-as-atomic
(dynamic-wind
start-atomic
(lambda ()
(let ([pool (tell (tell NSAutoreleasePool alloc) init)])
(dynamic-wind
void
thunk
(lambda ()
(tellv pool release)))))))
(tellv pool release)))))
end-atomic))

View File

@ -4984,7 +4984,11 @@ void scheme_start_atomic_no_break(void)
void scheme_end_atomic_no_swap(void)
{
--do_atomic;
int v = --do_atomic;
if (v < 0) {
scheme_log_abort("unbalanced end-atomic");
abort();
}
}
void scheme_start_in_scheduler(void)
@ -4995,8 +4999,12 @@ void scheme_start_in_scheduler(void)
void scheme_end_in_scheduler(void)
{
--do_atomic;
int v = --do_atomic;
--scheme_no_stack_overflow;
if (v < 0) {
scheme_log_abort("unbalanced end-atomic");
abort();
}
}
void scheme_end_atomic(void)