Bug 13891

Summary: insane.bbclass: do_package_qa hangs when checking a FIFO (named pipe) file
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Ahmed Hossam <Ahmed.Hossam>
Component: coreAssignee: Trevor Woerner <twoerner>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: meta.mr.watcher, meta.watcher, randy.macleod, twoerner
Version: 2.6.4   
Target Milestone: 3.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Ahmed Hossam 2020-05-03 04:48:04 UTC
do_package_qa:package_qa_walk hangs when attempting to open a FIFO file in the package, specifically at elf.open() statement, this is because FIFOs block when opened for read.

To reproduce add the following to an example recipe:

DEPENDS += "coreutils-native"

FILES_${PN} += " \
    /usr/run \
"

do_install_append() {
    mkdir  -p ${D}/usr/run/${PN}
    mkfifo -m 0666 ${D}/usr/run/${PN}/fifo
}

P.S. It looks like this might be a regression as it was supposed to be fixed according to this mail in the mailing list: https://www.yoctoproject.org/pipermail/yocto/2016-February/028424.html
Comment 1 Ahmed Hossam 2020-05-03 04:54:21 UTC
A very bad workaround is to skip qa for the recipe:
python do_package_qa() {
    pass
}
Comment 2 Ahmed Hossam 2020-05-03 05:29:42 UTC
Reproduced on master SHA 7a5cc8659e4ba8f36bcb5322e246005d812efb59
Comment 3 Randy MacLeod 2020-05-07 07:38:11 UTC
Needs an automated test as well.
Comment 4 Trevor Woerner 2020-12-24 12:43:12 UTC
One of the tests in insane.bbclass (package_qa_check_shebang_size()) tries to read the contents of the object looking for the #!. If the object is a fifo, any read(2) of its contents will hang forever, waiting for contents to appear.

The patch to fix this is as follows and has been submitted to the mailing list:

    diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
    index cf2165c517..105d2a5ce8 100644
    --- a/meta/classes/insane.bbclass
    +++ b/meta/classes/insane.bbclass
    @@ -87,7 +87,8 @@ def package_qa_add_message(messages, section, new_msg):
 
     QAPATHTEST[shebang-size] = "package_qa_check_shebang_size"
     def package_qa_check_shebang_size(path, name, d, elf, messages):
    -    if os.path.islink(path) or elf:
    +    import stat
    +    if os.path.islink(path) or stat.S_ISFIFO(os.stat(path).st_mode) or elf:
             return
 
         try:

The patch is here:
    https://lists.openembedded.org/g/openembedded-core/topic/master_next_patch_1_3/79198302
Comment 5 Trevor Woerner 2020-12-27 06:45:42 UTC
A patch to add an automated test is:
https://lists.openembedded.org/g/openembedded-core/message/146221
Comment 6 Randy MacLeod 2021-04-29 15:53:10 UTC
Fix in oe-core:

https://git.openembedded.org/openembedded-core/commit/?id=a7b1d22e93c8846d84a9855876038c2b38958dec

$ git branch -a --contains a7b1d22e93c
  hardknott
  master

Test:
https://git.openembedded.org/openembedded-core/commit/?id=53988b6389ce618d4cff52bd09ae91108beca354

$ git branch -a --contains 53988b6389ce618d4cff52bd09ae91108beca354
  hardknott
  master

Thanks Trevor!