<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>12228</bug_id>
          
          <creation_ts>2017-10-16 11:34:15 +0000</creation_ts>
          <short_desc>Race between do_make_sccripts() and recipes using the scripts it creates</short_desc>
          <delta_ts>2018-02-28 01:58:49 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>2.3.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.5 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Peter Kjellerstedt">peter.kjellerstedt</reporter>
          <assigned_to name="Bruce Ashfield">bruce.ashfield</assigned_to>
          <cc>joe.slater</cc>
    
    <cc>mark.hatle</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>77605</commentid>
    <comment_count>0</comment_count>
    <who name="Peter Kjellerstedt">peter.kjellerstedt</who>
    <bug_when>2017-10-16 11:34:15 +0000</bug_when>
    <thetext>Back in 2011, a lock (${TMPDIR}/kernel-scripts.lock) was introduced to protect do_make_scripts() from racing with itself when executed from different module recipes. The race was due to some of the kernel scripts always being rebuilt. 

Unfortunately this lock is not enough, since there is still a race between the scripts being rebuilt for one recipe and them being used by another. I.e., if do_make_script() is being executed for one kernel module recipe while another kernel module recipe is compiling, then there is a tiny chance that, e.g., modpost has been rewritten but not yet made executable by the first task at the same time as the second task tries to execute modpost, resulting in an error like this:

  /bin/sh: scripts/mod/modpost: Permission denied

My suggestion for a solution is to move do_make_scripts() from modules-base.bbclass to a recipe of its own (e.g., kernel-scripts) and then let modules.bbclass add a dependency on that recipe instead of adding the make_scripts task to the task list for the inheriting recipe. That way there should only ever be one recipe and task that creates the kernel scripts, and no race exists any more (which also means the lock file is no longer needed).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77633</commentid>
    <comment_count>1</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-10-17 12:25:47 +0000</bug_when>
    <thetext>Joe Slater has already sent a patch to do this in the past. I&apos;ll try and dig it up from the mailing list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77638</commentid>
    <comment_count>2</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-10-17 15:45:35 +0000</bug_when>
    <thetext>Attached is the patch to do this.

I tested it here, and it works. I can re-submit to the list shortly, it would be nice to know if it works for Peter has well.

I&apos;m sure it&apos;ll take a few revisions to get in, but the concept is the same.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77640</commentid>
    <comment_count>3</comment_count>
      <attachid>4086</attachid>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-10-17 15:47:11 +0000</bug_when>
    <thetext>Created attachment 4086
initial implementation patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77645</commentid>
    <comment_count>4</comment_count>
    <who name="Peter Kjellerstedt">peter.kjellerstedt</who>
    <bug_when>2017-10-17 20:28:17 +0000</bug_when>
    <thetext>The attached patch looks more or less exactly as what I had in mind. The only comment I have is that I believe that the dependency:

do_compile[depends] += &quot;virtual/kernel:do_compile_kernelmodules&quot;

in the new recipe should be:

do_compile[depends] += &quot;virtual/kernel:do_shared_workdir&quot;

When it comes to testing, I have no real test case. I have only seen it happen once in all the time I have used OE, and based my report on my analysis of the code after it happened.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77960</commentid>
    <comment_count>5</comment_count>
    <who name="Peter Kjellerstedt">peter.kjellerstedt</who>
    <bug_when>2017-11-03 20:44:36 +0000</bug_when>
    <thetext>The patch creates the make-mod-scripts recipe in meta-skeleton, but that shall of course be in meta...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77961</commentid>
    <comment_count>6</comment_count>
    <who name="Peter Kjellerstedt">peter.kjellerstedt</who>
    <bug_when>2017-11-04 00:01:57 +0000</bug_when>
    <thetext>And the make-mod-scripts recipe needs to inherit pkgconfig.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78240</commentid>
    <comment_count>7</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2017-11-16 14:29:51 +0000</bug_when>
    <thetext>Thanks for the comments. I&apos;m back on this now and will do some tweaks before posting a new version</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4086</attachid>
            <date>2017-10-17 15:47:11 +0000</date>
            <delta_ts>2017-10-17 15:47:11 +0000</delta_ts>
            <desc>initial implementation patch</desc>
            <filename>0001-make-mod-scripts-change-how-some-kernel-module-tools.patch</filename>
            <type>text/plain</type>
            <size>3537</size>
            <attacher name="Bruce Ashfield">bruce.ashfield</attacher>
            
              <data encoding="base64">RnJvbSA2YWI4MjliY2FiMmMxNTdiMDM3YWE3NzUwNjY5OTcxYTQ2N2FhYmFlIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKb2UgU2xhdGVyIDxqc2xhdGVyQHdpbmRyaXZlci5jb20+CkRh
dGU6IFRodSwgMjcgSnVsIDIwMTcgM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