Skip to content

Commit ff2ce4c

Browse files
committed
Protect sticky module requirement whatever its load order on purge
The requirement check on purge only looked at dependent modules loaded after the module to unload. A requirement loaded after its super-sticky dependent, for instance reloaded after a forced unload, was purged and left this dependent with a missing dependency, the very situation this protection aims to avoid. Look at dependent modules whatever their load order and drop the direct dependent pre-check that relied on load order too. Also cover the abort of the purge when the error raised for a retained requirement occurs with abort_on_error configured for this sub-command. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent c24e948 commit ff2ce4c

3 files changed

Lines changed: 81 additions & 1 deletion

File tree

‎doc/source/design/sticky-modules.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Specification
5252
and super-sticky modules
5353

5454
- Direct and indirect requirements are preserved, even without a sticky tag
55+
- Requirements are preserved whatever their load order relative to their
56+
dependent, as a requirement may be loaded after its dependent
5557
- Only strong requirements are preserved: an alternative requirement may
5658
be unloaded while another loaded module still satisfies it
5759
- A forced ``purge`` unloads sticky modules and can unload their

‎tcl/modeval.tcl‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,9 @@ proc isModuleSticky {mod} {
961961

962962
proc getModuleStickyDependentTag {mod} {
963963
set sticky_tag {}
964-
foreach dep_mod [getDependentLoadedModuleList [list $mod] 1 0 0 0] {
964+
# look at dependents whatever their load order to also protect a
965+
# requirement loaded after its sticky dependent
966+
foreach dep_mod [getDependentLoadedModuleList [list $mod] 1 0 1 0] {
965967
if {[isModuleTagged $dep_mod super-sticky 1]} {
966968
set sticky_tag super-sticky
967969
break

‎testsuite/modules.50-cmds/464-sticky_purge.exp‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,82 @@ foreach {report_mode msg reqmsg stickymsg} [list error\
250250
}
251251

252252

253+
# requirement loaded after its super-sticky dependent
254+
setenv_loaded_module [list sticky2/1.0 sticky1/1.0] [list\
255+
$mp/sticky2/1.0 $mp/sticky1/1.0]
256+
setenv_var __MODULES_LMTAG sticky2/1.0&super-sticky
257+
foreach {report_mode msg reqmsg} [list error $err_superstickyunload\
258+
$err_superstickyrequnload warning $warn_superstickyunload\
259+
$warn_superstickyrequnload silent {} {}] {
260+
setenv_var MODULES_STICKY_PURGE $report_mode
261+
set ans [list]
262+
if {$report_mode eq {error}} {
263+
lappend ans [list ERR]
264+
}
265+
set tserr {}
266+
if {$report_mode ne {silent}} {
267+
set tserr [msg_unload sticky1/1.0 $reqmsg]\n\n[msg_unload\
268+
{sticky2/1.0 <sS>} $msg]
269+
}
270+
testouterr_cmd sh {purge} $ans $tserr
271+
testouterr_cmd sh {purge -f} $ans $tserr
272+
}
273+
274+
275+
# requirement loaded after its sticky dependent
276+
setenv_var __MODULES_LMTAG sticky2/1.0&sticky
277+
foreach {report_mode msg reqmsg} [list error $err_stickyunload\
278+
$err_stickyrequnload warning $warn_stickyunload $warn_stickyrequnload\
279+
silent {} {}] {
280+
setenv_var MODULES_STICKY_PURGE $report_mode
281+
set ans [list]
282+
if {$report_mode eq {error}} {
283+
lappend ans [list ERR]
284+
}
285+
set tserr {}
286+
if {$report_mode ne {silent}} {
287+
set tserr [msg_unload sticky1/1.0 $reqmsg]\n\n[msg_unload\
288+
{sticky2/1.0 <S>} $msg]
289+
}
290+
testouterr_cmd sh {purge} $ans $tserr
291+
292+
set ans [list]
293+
foreach var {__MODULES_LMPREREQ _LMFILES_ LOADEDMODULES __MODULES_LMTAG} {
294+
lappend ans [list unset $var]
295+
}
296+
set tserr [msg_unload {sticky2/1.0 <S>} $err_stickyunloadf]
297+
testouterr_cmd sh {purge -f} $ans $tserr
298+
}
299+
300+
301+
# skipped requirement unload aborts purge if abort_on_error is configured
302+
setenv_var MODULES_ABORT_ON_ERROR purge
303+
setenv_loaded_module [list foo/1.0 sticky2/1.0 sticky1/1.0] [list\
304+
$mp/foo/1.0 $mp/sticky2/1.0 $mp/sticky1/1.0]
305+
setenv_var __MODULES_LMTAG sticky2/1.0&super-sticky
306+
307+
setenv_var MODULES_STICKY_PURGE error
308+
set tserr [msg_unload sticky1/1.0 $err_superstickyrequnload]
309+
testouterr_cmd sh {purge} ERR $tserr
310+
# force mode disables abort behavior
311+
set ans [list]
312+
lappend ans [list set _LMFILES_ $mp/sticky2/1.0:$mp/sticky1/1.0]
313+
lappend ans [list set LOADEDMODULES sticky2/1.0:sticky1/1.0]
314+
lappend ans [list ERR]
315+
set tserr [msg_unload sticky1/1.0 $err_superstickyrequnload]\n\n[msg_unload\
316+
{sticky2/1.0 <sS>} $err_superstickyunload]
317+
testouterr_cmd sh {purge -f} $ans $tserr
318+
319+
setenv_var MODULES_STICKY_PURGE warning
320+
set ans [list]
321+
lappend ans [list set _LMFILES_ $mp/sticky2/1.0:$mp/sticky1/1.0]
322+
lappend ans [list set LOADEDMODULES sticky2/1.0:sticky1/1.0]
323+
set tserr [msg_unload sticky1/1.0 $warn_superstickyrequnload]\n\n[msg_unload\
324+
{sticky2/1.0 <sS>} $warn_superstickyunload]
325+
testouterr_cmd sh {purge} $ans $tserr
326+
testouterr_cmd sh {purge -f} $ans $tserr
327+
328+
unsetenv_var MODULES_ABORT_ON_ERROR
253329
unsetenv_var __MODULES_LMPREREQ
254330
unsetenv_var TESTSUITE_STICKY
255331

0 commit comments

Comments
 (0)