<!-- 
RSS generated by JIRA (9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c) at Sat Feb 10 02:35:18 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>Whamcloud Community JIRA</title>
    <link>https://jira.whamcloud.com</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.4.14</version>
        <build-number>940014</build-number>
        <build-date>05-12-2023</build-date>
    </build-info>


<item>
            <title>[LU-10461] sanity 77c failure due to variables called in cleanup routine are out of scope</title>
                <link>https://jira.whamcloud.com/browse/LU-10461</link>
                <project id="10000" key="LU">Lustre</project>
                    <description>&lt;p&gt;In sanity test 77c, we call cleanup_77c() at the end of the test to cleanup at the end of the test and a trap is set to call the clean up function when the test is exited. cleanup_77c() uses variables from test_77c which are declared local. From sanity.sh:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;6375 cleanup_77c() {
6376         trap 0
6377         set_checksums 0
6378         $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
6379         $check_ost &amp;amp;&amp;amp;
6380                 do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
6381         [ -n $osc_file_prefix ] &amp;amp;&amp;amp; rm -f ${osc_file_prefix}*
6382         $check_ost &amp;amp;&amp;amp; [ -n $ost_file_prefix ] &amp;amp;&amp;amp;
6383                 do_facet ost1 rm -f ${ost_file_prefix}\*
6384 }
6385 
6386 test_77c() {
6387         [ $PARALLEL == &quot;yes&quot; ] &amp;amp;&amp;amp; skip &quot;skip parallel run&quot; &amp;amp;&amp;amp; return
6388         $GSS &amp;amp;&amp;amp; skip &quot;could not run with gss&quot; &amp;amp;&amp;amp; return
6389 
6390         local bad1
6391         local osc_file_prefix
6392         local osc_file
6393         local check_ost=false
6394         local ost_file_prefix
6395         local ost_file
6396         local orig_cksum
6397         local dump_cksum
6398         local fid
6399 
&#8230;
6417         osc_file_prefix=$($LCTL get_param -n debug_path)
6418         osc_file_prefix=${osc_file_prefix}-checksum_dump-osc-\\${fid}
6419 
6420         trap cleanup_77c EXIT
&#8230;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When the test exits normally and cleanup_77c() is called at the end of the test, there is no issue; the variables from the test are still in scope. &lt;/p&gt;

&lt;p&gt;There is a problem when we exit test_77c when we encounter an error or exit the test before calling cleanup_77c. In these cases, the trap specified in line 6420 is invoked and cleanup_77c() is called. Yet, the variables that are local to test_77c are no longer visible to the cleanup routine. &lt;/p&gt;

&lt;p&gt;One fix for this is to increase the scope of the variables, remove &#8220;local&#8221;, and this should fix the problem. What are other solutions?&lt;/p&gt;

&lt;p&gt;Logs for this test failing are at:&lt;br/&gt;
&lt;a href=&quot;https://testing.hpdd.intel.com/test_sets/9dbb758a-e767-11e7-8027-52540065bddc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://testing.hpdd.intel.com/test_sets/9dbb758a-e767-11e7-8027-52540065bddc&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;https://testing.hpdd.intel.com/test_sets/6958de42-f002-11e7-854b-52540065bddc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://testing.hpdd.intel.com/test_sets/6958de42-f002-11e7-854b-52540065bddc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I suspect there are more examples of this issue in our test suites.&lt;/p&gt;</description>
                <environment></environment>
        <key id="50057">LU-10461</key>
            <summary>sanity 77c failure due to variables called in cleanup routine are out of scope</summary>
                <type id="1" iconUrl="https://jira.whamcloud.com/secure/viewavatar?size=xsmall&amp;avatarId=11303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.whamcloud.com/images/icons/priorities/minor.svg">Minor</priority>
                        <status id="5" iconUrl="https://jira.whamcloud.com/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="1">Fixed</resolution>
                                        <assignee username="jamesanunez">James Nunez</assignee>
                                    <reporter username="jamesanunez">James Nunez</reporter>
                        <labels>
                            <label>tests</label>
                    </labels>
                <created>Fri, 5 Jan 2018 00:20:49 +0000</created>
                <updated>Tue, 2 Apr 2019 03:34:36 +0000</updated>
                            <resolved>Mon, 9 Apr 2018 20:42:43 +0000</resolved>
                                    <version>Lustre 2.11.0</version>
                    <version>Lustre 2.10.2</version>
                                    <fixVersion>Lustre 2.12.0</fixVersion>
                    <fixVersion>Lustre 2.10.7</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>5</watches>
                                                                            <comments>
                            <comment id="217594" author="bfaccini" created="Fri, 5 Jan 2018 16:27:00 +0000"  >&lt;p&gt;Hmm, I am sure to be far to know all bash tricky behaviors but I remember that for particular sanity/test_77c case I made some testing to verify the scope of local vs exit/trap context like following :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;[root@eagle-29 test_trap_with_local]# cat foo.sh
#!/bin/bash

footrap() {
trap 0
echo &quot;foo=&quot; $foo
}

fooerror() {
exit 1
}

foofunc() {
local foo
trap footrap EXIT
foo=foo

#exit
fooerror
}

foofunc

[root@eagle-29 test_trap_with_local]# bash foo.sh
foo= foo
[root@eagle-29 test_trap_with_local]# 
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="217621" author="jamesanunez" created="Fri, 5 Jan 2018 19:40:35 +0000"  >&lt;p&gt;Bruno - I agree that your example works and the variable scope in the original test code worked. Patch &lt;a href=&quot;https://review.whamcloud.com/#/c/30653/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/#/c/30653/&lt;/a&gt; is adding a &quot;return 0&quot; after the call to skip so we exit the test code early at:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;	$check_ost || skip &lt;span class=&quot;code-quote&quot;&gt;&quot;No need to check cksum dump on OSS&quot;&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This changes the behavior of the test to:&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;#!/usr/bin/bash

footrap() {
trap 0
echo &lt;span class=&quot;code-quote&quot;&gt;&quot;foo=&quot;&lt;/span&gt; $foo
}

fooerror() {
exit 1
}

foofunc() {
local foo
trap footrap EXIT

foo=foo

# exit early
[ $foo == &lt;span class=&quot;code-quote&quot;&gt;&apos;foo&apos;&lt;/span&gt; ] &amp;amp;&amp;amp; &lt;span class=&quot;code-keyword&quot;&gt;return&lt;/span&gt; 0

fooerror
}

foofunc
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Perhaps I should word the description/title of this ticket differently.&lt;/p&gt;</comment>
                            <comment id="217662" author="bfaccini" created="Sat, 6 Jan 2018 16:03:54 +0000"  >&lt;p&gt;Ok, I better understand now how the local can become out-of-scope! And may be I have also been wrong originally to make the assumption that skip() wad ending with an &quot;exit 0&quot;, like is error() doing with an &quot;exit 1&quot;.&lt;/p&gt;

&lt;p&gt;So, may be we should not &quot;return 0&quot; after calling skip(), as done now in &lt;a href=&quot;https://review.whamcloud.com/#/c/[30402,30653]/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/#/c/[30402,30653]/&lt;/a&gt; but instead &quot;exit 0&quot; !! What do you think?&lt;/p&gt;
</comment>
                            <comment id="217876" author="adilger" created="Wed, 10 Jan 2018 06:41:18 +0000"  >&lt;p&gt;Quentin and I discussed this same issue in patch &lt;a href=&quot;https://review.whamcloud.com/29653&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/29653&lt;/a&gt; &quot;&lt;a href=&quot;https://jira.whamcloud.com/browse/LU-9474&quot; title=&quot;tests: register traps in a correct order&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-9474&quot;&gt;&lt;del&gt;LU-9474&lt;/del&gt;&lt;/a&gt; tests: add the stack_trap() utility function&quot;, and the conclusion was that the local variables would remain in scope for the exit trap.&lt;/p&gt;

&lt;p&gt;I&apos;m not sure if &lt;tt&gt;stack_trap&lt;/tt&gt; itself avoids the local issue, or that by using &lt;tt&gt;stack_trap&lt;/tt&gt; we can just avoid having complex cleanup functions that reference local variables.&lt;/p&gt;</comment>
                            <comment id="217880" author="bougetq" created="Wed, 10 Jan 2018 10:23:24 +0000"  >&lt;p&gt;James is right in that on &quot;normal exit&quot; (with &lt;tt&gt;return&lt;/tt&gt;, rather than &lt;tt&gt;exit&lt;/tt&gt;), local variables are wiped before the trap is run (I did not know until now).&lt;/p&gt;

&lt;p&gt;I can see two ways out of this:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;use &lt;tt&gt;exit 0&lt;/tt&gt; instead of &lt;tt&gt;return 0&lt;/tt&gt; (in the skip function);&lt;/li&gt;
	&lt;li&gt;use &lt;tt&gt;stack_trap()&lt;/tt&gt; to evaluate variables at registration.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;For example in test_77c, that would give something like :&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;test_77c() {
    [...]
    stack_trap &quot;set_checksums 0&quot; EXIT
    set_checksums 1
    [...]
    stack_trap &quot;$LCTL set_param osc.*osc-[^mM]*.checksum_dump=0&quot; EXIT
    $LCTL set_param osc.*osc-[^mM]*.checksum_dump=1
    [...]
    if $check_ost; then
        stack_trap &quot;do_facet ost1 \
                    $LCTL set_param obdfilter.*-OST*.checkum_dump=0&quot; EXIT
        do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=1
    fi
    [...]
    # I am not really sure where the last two traps should go so this needs checking
    [ -n &quot;$osc_file_prefix&quot; ] &amp;amp;&amp;amp; stack_trap &quot;rm -f &apos;$osc_file_prefix&apos;*&quot; EXIT
    dd if=$DIR/$tfile of=/dev/null bs=1M || error &quot;dd read error: $?&quot;
    [...]
    $check_ost || skip &quot;No need to check cksum dump on OSS&quot;
    [ -n &quot;$ost_file_prefix&quot; ] &amp;amp;&amp;amp;
        stack_trap &quot;do_facet ost1 \&quot;rm -f &apos;$ost_file_prefix&apos;*\&quot;&quot; EXIT
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that until &lt;a href=&quot;https://review.whamcloud.com/#/c/30490/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this patch&lt;/a&gt; lands, using single quotes inside traps does not work as intended for &lt;tt&gt;stack_trap()&lt;/tt&gt;.&lt;/p&gt;</comment>
                            <comment id="217881" author="bfaccini" created="Wed, 10 Jan 2018 11:04:32 +0000"  >&lt;p&gt;Andreas, since Quentin is also ok with my previous fix idea to &quot;exit 0&quot; in/after skip(), may be we can just go for it as it looks pretty simple. What do you think?&lt;/p&gt;</comment>
                            <comment id="217882" author="bougetq" created="Wed, 10 Jan 2018 11:47:05 +0000"  >&lt;p&gt;For the record, why isn&apos;t there a &lt;tt&gt;skip_noexit()&lt;/tt&gt; and why isn&apos;t &lt;tt&gt;skip()&lt;/tt&gt; exiting the test itself?&lt;/p&gt;</comment>
                            <comment id="217896" author="jamesanunez" created="Wed, 10 Jan 2018 15:25:36 +0000"  >&lt;p&gt;I agree that we are being inconsistent with error() calling exit and skip() not calling exit. Let me look into adding exit to skip and if we need a skip_noexit(). Thank you all for the comments on this issue.&lt;/p&gt;
</comment>
                            <comment id="218781" author="gerrit" created="Sun, 21 Jan 2018 22:33:02 +0000"  >&lt;p&gt;James Nunez (james.a.nunez@intel.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/30964&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/30964&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10461&quot; title=&quot;sanity 77c failure due to variables called in cleanup routine are out of scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10461&quot;&gt;&lt;del&gt;LU-10461&lt;/del&gt;&lt;/a&gt; tests: exit in the skip routine&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: e85b9f63926d775db60b9af7f1be3039d766b121&lt;/p&gt;</comment>
                            <comment id="225485" author="gerrit" created="Mon, 9 Apr 2018 19:48:35 +0000"  >&lt;p&gt;Oleg Drokin (oleg.drokin@intel.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/30964/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/30964/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10461&quot; title=&quot;sanity 77c failure due to variables called in cleanup routine are out of scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10461&quot;&gt;&lt;del&gt;LU-10461&lt;/del&gt;&lt;/a&gt; tests: call exit in the skip routine&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 33aad7829de56353cca5bbd082d95d6821a7be9c&lt;/p&gt;</comment>
                            <comment id="225536" author="pjones" created="Mon, 9 Apr 2018 20:42:43 +0000"  >&lt;p&gt;Landed for 2.12&lt;/p&gt;</comment>
                            <comment id="225681" author="gerrit" created="Tue, 10 Apr 2018 20:43:44 +0000"  >&lt;p&gt;James Nunez (james.a.nunez@intel.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/31942&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/31942&lt;/a&gt;&lt;br/&gt;
Subject: Revert &quot;&lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10461&quot; title=&quot;sanity 77c failure due to variables called in cleanup routine are out of scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10461&quot;&gt;&lt;del&gt;LU-10461&lt;/del&gt;&lt;/a&gt; tests: call exit in the skip routine&quot;&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: master&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: b210d5d2db976070b46b90867d9dc275bb329f3f&lt;/p&gt;</comment>
                            <comment id="239837" author="gerrit" created="Fri, 11 Jan 2019 19:23:09 +0000"  >&lt;p&gt;James Nunez (jnunez@whamcloud.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/34015&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34015&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10461&quot; title=&quot;sanity 77c failure due to variables called in cleanup routine are out of scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10461&quot;&gt;&lt;del&gt;LU-10461&lt;/del&gt;&lt;/a&gt; tests: call exit in the skip routine&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: b2_10&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: 3b92d212abebcaf1c955b03ba4f0ecfcc125e901&lt;/p&gt;</comment>
                            <comment id="239914" author="gerrit" created="Mon, 14 Jan 2019 18:21:46 +0000"  >&lt;p&gt;James Nunez (jnunez@whamcloud.com) uploaded a new patch: &lt;a href=&quot;https://review.whamcloud.com/34023&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34023&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10461&quot; title=&quot;sanity 77c failure due to variables called in cleanup routine are out of scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10461&quot;&gt;&lt;del&gt;LU-10461&lt;/del&gt;&lt;/a&gt; tests: call exit in the skip routine&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: b2_10&lt;br/&gt;
Current Patch Set: 1&lt;br/&gt;
Commit: f1b695016446fa0d7169c2caf2149f0593c2abd6&lt;/p&gt;</comment>
                            <comment id="240376" author="gerrit" created="Sat, 19 Jan 2019 06:29:00 +0000"  >&lt;p&gt;Oleg Drokin (green@whamcloud.com) merged in patch &lt;a href=&quot;https://review.whamcloud.com/34023/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://review.whamcloud.com/34023/&lt;/a&gt;&lt;br/&gt;
Subject: &lt;a href=&quot;https://jira.whamcloud.com/browse/LU-10461&quot; title=&quot;sanity 77c failure due to variables called in cleanup routine are out of scope&quot; class=&quot;issue-link&quot; data-issue-key=&quot;LU-10461&quot;&gt;&lt;del&gt;LU-10461&lt;/del&gt;&lt;/a&gt; tests: call exit in the skip routine&lt;br/&gt;
Project: fs/lustre-release&lt;br/&gt;
Branch: b2_10&lt;br/&gt;
Current Patch Set: &lt;br/&gt;
Commit: 8c6308656bb4de6b661ab60226a45ec8ae7729fe&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Related</name>
                                            <outwardlinks description="is related to ">
                                        <issuelink>
            <issuekey id="45959">LU-9474</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="55326">LU-12146</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="52200">LU-11010</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_10890" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10390" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzzqjr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10090" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10060" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Severity</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10022"><![CDATA[3]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>