Bug 9798 - Files in ~/tmp being deleted during a build
Summary: Files in ~/tmp being deleted during a build
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.0
Hardware: x86 Multiple
: Medium+ major
Target Milestone: 2.2 M2
Assignee: Ross Burton
QA Contact: Francisco Pedraza
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-06-17 09:58 UTC by Paul Eggleton
Modified: 2016-07-01 16:05 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
Results of ausearch with audit tracing enabled on ~/tmp (3.68 KB, text/plain)
2016-06-17 09:58 UTC, Paul Eggleton
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggleton 2016-06-17 09:58:39 UTC
Created attachment 3238 [details]
Results of ausearch with audit tracing enabled on ~/tmp

So for a while now on my Fedora 23 build machine all the files in my ~/tmp directory were being deleted on an irregular basis (just that directory, not recursively). I had a hunch it was happening at the same time as rebuilding something early in the build process and I'd set up a canary and script to try to track down what was doing it, but it wasn't until yesterday I actually caught it with the audit system - see attached. There were a number of these events, one per entry in my ~/tmp so it was clearly looping through all of the items in that directory and calling unlink() on them.

There are a bunch of interesting things in the log entries but the most significant is that the apparent executable running is /usr/bin/ccache. Richard dug into the ccache source and found that as part of cleanup it was deleting CCACHE_DIR/tmp, and then found that CCACHE_DIR is being set by us in bitbake.conf to $HOME if it's not set (which it isn't in my environment):

-------- snip --------
# Assign CCACHE_DIR a default value to fix a bug of ccache 3.1.7,
# since it would always create CCACHE_DIR/.ccache even if
# CCACHE_DISABLE = 1.
export CCACHE_DIR ??= "${@os.getenv('HOME')}"
-------- snip --------

Given the results I really don't think this is a good idea. We need to investigate whether we really still need this and if we do, default it to something much more sensible. Luckily I don't think I've lost anything valuable with these deletions, but someone else might not be so fortunate.
Comment 1 Ross Burton 2016-06-20 12:04:01 UTC
I'm not sure why the assignment of CCACHE_DIR was made, as the default value for CCACHE_DIR if it isn't set is $HOME/.ccache/.  I don't see what harm ccache touching that would cause compared to $HOME.

Note that if ccache.bbclass is actually inherited then CCACHE_DIR is assigned there:

export CCACHE_DIR = "${TMPDIR}/ccache/${MULTIMACH_HOST_SYS}/${PN}"

Robert, you wrote the patch that introduced this back in 2012 (oe-core d2bab9b), do you remember why you set CCACHE_DIR to just $HOME in bitbake.conf?  If ccache still has the bug where autogen sets HOME=/dev/null then I'd be inclined to either patch autogen to remove that, or set CCACHE to $HOME/.ccache in bitbake.conf (which will expand to a full path before autogen can destroy it).
Comment 2 Ross Burton 2016-06-20 12:12:06 UTC
The ccache bug mentioned was fixed in ccache 3.1.10, released 2014-10-19 (even Debian Stable has this).  I think we should just remove that line.
Comment 3 Ross Burton 2016-06-23 14:41:58 UTC
Fixed in oe-core 15eaf9cb1fa19036fe4442905876dae94070b04d.