@@ -1094,8 +1094,15 @@ Job *DefaultActorImpl::claimNextJobOrGiveUp(bool actorIsOwned,
1094
1094
// / the current thread, and keep processing whatever actor we're
1095
1095
// / running when code returns back to us until we're not processing
1096
1096
// / any actors anymore.
1097
+ // /
1098
+ // / \param currentActor is expected to be passed in as retained to ensure that
1099
+ // / the actor lives for the duration of job execution.
1100
+ // / Note that this may conflict with the retain/release
1101
+ // / design in the DefaultActorImpl, but it does fix bugs!
1097
1102
static void processDefaultActor (DefaultActorImpl *currentActor,
1098
1103
RunningJobInfo runner) {
1104
+ DefaultActorImpl *actor = currentActor;
1105
+
1099
1106
// Register that we're processing a default actor in this frame.
1100
1107
ExecutorTrackingInfo trackingInfo;
1101
1108
auto activeTrackingInfo = trackingInfo.enterOrUpdate (
@@ -1142,6 +1149,8 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
1142
1149
// If we still have an active actor, we should give it up.
1143
1150
if (currentActor)
1144
1151
currentActor->giveUpThread (runner);
1152
+
1153
+ swift_release (actor);
1145
1154
}
1146
1155
1147
1156
void ProcessInlineJob::process (Job *job, ExecutorRef _executor) {
@@ -1153,6 +1162,7 @@ void ProcessInlineJob::process(Job *job, ExecutorRef _executor) {
1153
1162
auto runner = RunningJobInfo::forInline (targetPriority);
1154
1163
1155
1164
// FIXME: force tail call
1165
+ swift_retain (actor);
1156
1166
return processDefaultActor (actor, runner);
1157
1167
}
1158
1168
@@ -1168,6 +1178,7 @@ void ProcessOutOfLineJob::process(Job *job, ExecutorRef _executor) {
1168
1178
delete self;
1169
1179
1170
1180
// FIXME: force tail call
1181
+ swift_retain (actor);
1171
1182
return processDefaultActor (actor, runner);
1172
1183
}
1173
1184
@@ -1179,6 +1190,7 @@ void ProcessOverrideJob::process(Job *job, ExecutorRef _executor) {
1179
1190
auto runner = RunningJobInfo::forOverride (self);
1180
1191
1181
1192
// FIXME: force tail call
1193
+ swift_retain (actor);
1182
1194
return processDefaultActor (actor, runner);
1183
1195
}
1184
1196
0 commit comments