From: Kevin Day Date: Mon, 12 Apr 2021 00:14:06 +0000 (-0500) Subject: Cleanup: remove "local" workaround in execute function. X-Git-Tag: 0.5.3~52 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=3859e3d59c35da0c5d502fa6f62da40ed5348351;p=fll Cleanup: remove "local" workaround in execute function. At the time I was unable to determine the cause. Now, I strongly suspect it was due to the way threads were being created on the parent stack and the child threads could not access them once a resize function happened. The resize can, on occasion (and likely more often than not), relocate the address location of the range (array). This relocation in memory likely caused the weird memory behavior. Now that the memory is allocated such that the it is an array of allocated pointers, the memory addresses should not change when the array of pointers is resized. The address to the pointers might change, but from the perspective of the child threads, they don't exist or otherwise matter anyway. Removing the work around cleans up some clutter and what is essentially a waste of resources. --- diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index 13a7f2b..32e8bd0 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -764,21 +764,8 @@ extern "C" { controller_execute_set_t execute_set = controller_macro_execute_set_t_initialize(0, 0, &environment, &signals, 0, fl_execute_as_t_initialize); - // when using pointers in threads and calling the exec functions, invalid reads and writes may occur. - // this problem might be happening due to a compiler optimization/decision, so make local copies and have the pointers reference these to avoid invalid reads and writes. - int local_nice; - uid_t local_id_user; - gid_t local_id_group; - - f_int32s_t local_affinity; - f_control_group_t local_control_group; - f_int32s_t local_id_groups; - f_limit_sets_t local_limits; - f_execute_scheduler_t local_scheduler; - if (process->rule.affinity.used) { - local_affinity = process->rule.affinity; - execute_set.as.affinity = &local_affinity; + execute_set.as.affinity = &process->rule.affinity; } if (process->rule.capability) { @@ -786,8 +773,7 @@ extern "C" { } if (process->rule.has & controller_rule_has_control_group) { - local_control_group = process->rule.control_group; - execute_set.as.control_group = &local_control_group; + execute_set.as.control_group = &process->rule.control_group; // make sure all required cgroup directories exist. if (process->status == F_known_not) { @@ -802,33 +788,27 @@ extern "C" { } if (process->rule.has & controller_rule_has_group) { - local_id_group = process->rule.group; - execute_set.as.id_group = &local_id_group; + execute_set.as.id_group = &process->rule.group; if (process->rule.groups.used) { - local_id_groups = process->rule.groups; - execute_set.as.id_groups = &local_id_groups; + execute_set.as.id_groups = &process->rule.groups; } } if (process->rule.limits.used) { - local_limits = process->rule.limits; - execute_set.as.limits = &local_limits; + execute_set.as.limits = &process->rule.limits; } if (process->rule.has & controller_rule_has_scheduler) { - local_scheduler = process->rule.scheduler; - execute_set.as.scheduler = &local_scheduler; + execute_set.as.scheduler = &process->rule.scheduler; } if (process->rule.has & controller_rule_has_nice) { - local_nice = process->rule.nice; - execute_set.as.nice = &local_nice; + execute_set.as.nice = &process->rule.nice; } if (process->rule.has & controller_rule_has_user) { - local_id_user = process->rule.user; - execute_set.as.id_user = &local_id_user; + execute_set.as.id_user = &process->rule.user; } status = fl_environment_load_names(process->rule.environment, &environment);