Bug 7922 - Sanity test that files can be created in TMPDIR
Summary: Sanity test that files can be created in TMPDIR
Status: VERIFIED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 1.9
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: 1.9 M2
Assignee: Mariano Lopez
QA Contact: Daniel Istrate
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-06-24 22:25 UTC by Ross Burton
Modified: 2015-11-04 11:47 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ross Burton 2015-06-24 22:25:32 UTC
If /tmp can't be written to for whatever reason (say, no tmpfs and / is full up) then bitbake gives a very obscure error:

ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
    Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
    Following is the list of potential problems / advisories:

    Your gcc version is older than 4.5 or is not working properly.  Please verify you can build and link something that uses atomic operations, such as: 
        __sync_bool_compare_and_swap (&atomic, 2, 3);


(as gcc fails to write temporary files)

We should probably check that we can write a small file into $TMP as a very early sanity test before compiling.
Comment 1 Mariano Lopez 2015-06-29 15:26:31 UTC
The check must be done in /tmp (not TMPDIR)
Comment 2 Mariano Lopez 2015-06-29 15:27:11 UTC
Sent patch for review
Comment 3 Mariano Lopez 2015-07-07 15:38:40 UTC
This bug has been fixed with commit:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=cea20425a3dcb8868c53518cbec4b250076f1675
Comment 4 Mariano Lopez 2015-07-07 16:19:47 UTC
Adding the comments from Ross

    +    # Check if /tmp is writable
    +    from string import ascii_letters
    +    from random import choice
    +    filename = "bb_writetest.%s" % os.getpid()
    +    testfile = os.path.join("/tmp", filename)


Use tempfile.mkstemp() here, we'll get proper unique names and it will use the same temporary directory as gcc etc.
 

    +    try:
    +        f = open(testfile, "w")
    +        f.write("".join(choice(ascii_letters) for x in range(1024)))
    +        f.close()
    +        os.remove(testfile)
    +    except:
    +        status.addresult("Failed to write into /tmp. Please verify your filesystem.")


The error should include the message from the exception to help root-cause the problem.

Ross
Comment 5 Mariano Lopez 2015-07-07 19:26:37 UTC
Sent patch v2 based on master for review
Comment 6 Mariano Lopez 2015-07-22 14:04:25 UTC
This bug has been solved with commit:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=45772bab329821ad425b20e630749c2a6c82c235
Comment 7 Paul Eggleton 2015-11-02 14:53:25 UTC
FYI the fix mentioned above was reverted in favour of this one:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=9f87dcf3a3adf0b215b59eac854d372216c9dc0d
Comment 8 Daniel Istrate 2015-11-02 16:00:18 UTC
Verified on master: 370a2916c4559c17952392b872322e8e490b124c

As far as I can tell this bug was fixed and then the fix was removed in favor of http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=9f87dcf3a3adf0b215b59eac854d372216c9dc0d.

That fix only checks that /tmp has enough space. It does not check proper /tmp permissions.
So the case when you cannot create a file in /tmp due to wrong permissions is not covered.


**************** Test 1: change /tmp permissions to 555

[daniel@fedora-ws poky-build2]$ sudo chmod 555 /tmp
[daniel@fedora-ws poky-build2]$ bitbake ed
Parsing recipes: 100% |##############################################################################| ETA:  00:00:00
Parsing of 900 .bb files complete (0 cached, 900 parsed). 1330 targets, 38 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.28.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Fedora-21"
TARGET_SYS        = "i586-poky-linux"
MACHINE           = "qemux86"
DISTRO            = "poky"
DISTRO_VERSION    = "2.0"
TUNE_FEATURES     = "m32 i586"
TARGET_FPU        = ""
meta              
meta-yocto        
meta-yocto-bsp    = "master:370a2916c4559c17952392b872322e8e490b124c"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: autoreconf execution failed.
ERROR: Function failed: do_configure (log file is located at /media/ssd/poky-build2/tmp/work/x86_64-linux/gperf-native/3.0.4-r0/temp/log.do_configure.26594)
ERROR: Logfile of failure stored in: /media/ssd/poky-build2/tmp/work/x86_64-linux/gperf-native/3.0.4-r0/temp/log.do_configure.26594
Log data follows:
| DEBUG: Executing python function sysroot_cleansstate
| DEBUG: Python function sysroot_cleansstate finished
| DEBUG: Executing shell function autotools_preconfigure
| DEBUG: Shell function autotools_preconfigure finished
| DEBUG: Executing python function autotools_copy_aclocals
| DEBUG: SITE files ['endian-little', 'common-linux', 'common-glibc', 'bit-64', 'x86_64-linux', 'common']
| DEBUG: Python function autotools_copy_aclocals finished
| DEBUG: Executing shell function do_configure
| automake (GNU automake) 1.15
| Copyright (C) 2014 Free Software Foundation, Inc.
| License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>
| This is free software: you are free to change and redistribute it.
| There is NO WARRANTY, to the extent permitted by law.
| 
| Written by Tom Tromey <tromey@redhat.com>
|        and Alexandre Duret-Lutz <adl@gnu.org>.
| AUTOV is 1
| NOTE: Executing ACLOCAL="aclocal --system-acdir=/media/ssd/poky-build2/tmp/work/x86_64-linux/gperf-native/3.0.4-r0/build/aclocal-copy/" autoreconf --verbose --install --force --exclude=autopoint -I /media/ssd/poky-build2/tmp/work/x86_64-linux/gperf-native/3.0.4-r0/gperf-3.0.4
| autoreconf: cannot create /tmp/ar825.27062: Permission denied
|  at /media/ssd/poky-build2/tmp/sysroots/x86_64-linux/usr/bin/autoreconf line 732.
| ERROR: autoreconf execution failed.
| ERROR: Function failed: do_configure (log file is located at /media/ssd/poky-build2/tmp/work/x86_64-linux/gperf-native/3.0.4-r0/temp/log.do_configure.26594)
ERROR: Task 292 (virtual:native:/home/daniel/poky/meta/recipes-extended/gperf/gperf_3.0.4.bb, do_configure) failed with exit code '1'
NOTE: Tasks Summary: Attempted 147 tasks of which 120 didn't need to be rerun and 1 failed.
Waiting for 0 running tasks to finish:

Summary: 1 task failed:
  virtual:native:/home/daniel/poky/meta/recipes-extended/gperf/gperf_3.0.4.bb, do_configure
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

Revert back /tmp permissions
[daniel@fedora-ws poky-build2]$ sudo chmod 1777 /tmp


**************** Test 2: change /tmp size to less that 100MB (the fix mentioned in Comment 7)

[daniel@fedora-ws poky-build2]$ sudo mount -o remount,size=90m,noatime /tmp
[daniel@fedora-ws poky-build2]$ bitbake -c clean ed
Loading cache: 100% |################################################################################| ETA:  00:00:00
Loaded 1331 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.28.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Fedora-21"
TARGET_SYS        = "i586-poky-linux"
MACHINE           = "qemux86"
DISTRO            = "poky"
DISTRO_VERSION    = "2.0"
TUNE_FEATURES     = "m32 i586"
TARGET_FPU        = ""
meta              
meta-yocto        
meta-yocto-bsp    = "master:370a2916c4559c17952392b872322e8e490b124c"

NOTE: Preparing RunQueue
NOTE: Executing RunQueue Tasks
WARNING: The free space of /tmp (tmpfs) is running low (0.087GB left)
ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!
NOTE: Tasks Summary: Attempted 1 tasks of which 0 didn't need to be rerun and all succeeded.

Summary: There was 1 WARNING message shown.
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
Comment 9 Mariano Lopez 2015-11-03 15:20:23 UTC
This bug was opened because /tmp was running out of space in the autobuilders. With the patch that Paul mentioned this is being monitored during all the build. I think if you can't write in /tmp, there would be other major problems than running bitbake
Comment 10 Ross Burton 2015-11-04 11:21:37 UTC
I think I agree with Mariano here - if /tmp isn't writable at all then you'll be having far greater problems than bitbake not working: I'd be surprised if you can even login.  We should sanity check the environment but not check for catastrophic failure.
Comment 11 Daniel Istrate 2015-11-04 11:47:11 UTC
Checking if /tmp has sufficient free space is enough.