Bug 10116 - busybox parallel make race
Summary: busybox parallel make race
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.2
Hardware: x86 Multiple
: High normal
Target Milestone: 2.2 M4
Assignee: Juro Bystricky
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-08-11 16:49 UTC by Leonardo Sandoval Gonzalez
Modified: 2016-09-19 12:42 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
Complete log taken from AB (975.93 KB, text/plain)
2016-08-11 16:50 UTC, Leonardo Sandoval Gonzalez
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Leonardo Sandoval Gonzalez 2016-08-11 16:49:14 UTC
There is a failure on the AB [1] (also log attached) related to busybox do_compile task using musl-gcc compile. This is one of the issues observed but full log review is pending


| libbb/appletlib.c:164:13: error: 'NUM_APPLETS' undeclared (first use in this function)
|   while (i < NUM_APPLETS) {



[1] https://autobuilder.yoctoproject.org/main/builders/poky-tiny/builds/908
Comment 1 Leonardo Sandoval Gonzalez 2016-08-11 16:50:52 UTC
Created attachment 3349 [details]
Complete log taken from AB
Comment 2 Ross Burton 2016-08-11 19:00:18 UTC
Richard has been chasing this.
Comment 3 Leonardo Sandoval Gonzalez 2016-08-11 21:56:05 UTC
Another bug that may be related:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=10129
Comment 4 Richard Purdie 2016-08-17 14:46:04 UTC
(In reply to comment #3)
> Another bug that may be related:
> 
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=10129

Seems these are not related.
Comment 5 Richard Purdie 2016-08-17 15:07:34 UTC
I've backported a patch from busybox upstream related to this. I'm still not 100% convinced this fixes all the issues though. There is a discussion on the busybox mailing list about this.
Comment 6 Richard Purdie 2016-08-18 08:02:18 UTC
Appeared in selftest despite the makefile fix being applied: https://autobuilder.yoctoproject.org/main/builders/nightly-oe-selftest/builds/643/steps/Running%20oe-selftest/logs/stdio
Comment 7 Juro Bystricky 2016-08-24 23:27:39 UTC
The problem is fairly difficult to reproduce. I ran stress test several thousand times and reproduced the failure twice. On the positive side, it is always the same/identical error:

libbb/appletlib.c:164:13: error: 'NUM_APPLETS' undeclared (first use in this function)
  while (i < NUM_APPLETS) {
             ^~~~~~~~~~~

Based on the error, the file NUM_APPLETS.h (where NUM_APPLETS is defined) does not exist at the time of the compilation of the file appletlib.c. (The file NUM_APPLETS.h is generated as needed)

The proposed fix is to explicitly specify the dependency in libbb/Kbuild.src:

-libbb/appletlib.o: include/usage_compressed.h
+libbb/appletlib.o: include/usage_compressed.h include/NUM_APPLETS.h

This can take a while to verify, as the absence of evidence != evidence of absence. First we need to make sure we can reliably reproduce the error, then 
using the same stress test not observe the error.
Presently we are trying to enhance the stress test by running parallel builds in multiple Docker containers at the same time. (bitbake busybox -c compile -f)

(Also, looking at the bug, it does not seem to be poky-tiny specific).
Comment 8 Juro Bystricky 2016-08-24 23:34:08 UTC
This bug is discussed on the Busybox mailing list:
https://www.mail-archive.com/busybox@busybox.net/msg23244.html
Comment 9 Juro Bystricky 2016-08-25 23:13:25 UTC
The proposed fix did not solve the problem, if anything, the problem was exacerbated.
This means there are two (or more) parallel targets, all of which need the fo generate the file NUM_APPLETS.h, but with different contents. (NUM_APPLETS.h is only re-generated when its contents are modified).
Comment 10 Juro Bystricky 2016-08-26 00:01:41 UTC
I noticed there are some new patches related to this problem on the busybox git repo.
I am going to test them.
Comment 11 Juro Bystricky 2016-08-30 00:30:42 UTC
So far we ran stress test with the patch "parallel-make-fix.patch" at least 40,000 times without observing any failure....
(commit f755bab79246e129e60b71f20ea16f36393f40b2)
Comment 12 Juro Bystricky 2016-08-30 23:12:33 UTC
Build is eventually broken for yocto commit f755bab79246e129e60b71f20ea16f36393f40b2.

Build is also eventually broken with Busybox GIT commits addressing the problem:
0dddbc1a59795a77679d8c5ef48a2795cb4705630dddbc1 ("build system: always rewrite NUM_APPLETS.h", 2016-08-23)d8e61bb 

d8e61bbf13d0cf38d477255cfd5dc71c5d51d575 ("build system: different fix for include/applet_tables.h/include/NUM_APPLETS.h", 2016-08-21)

Always the same error observed.
Comment 13 Juro Bystricky 2016-09-14 23:51:42 UTC
Sent a patchset to the mailing list for a review:
http://lists.openembedded.org/pipermail/openembedded-core/2016-September/126511.html
Comment 14 Juro Bystricky 2016-09-14 23:53:36 UTC
Sent a patchset to the mailing list for a review:
http://lists.openembedded.org/pipermail/openembedded-core/2016-September/126511.html

(Also renamed the bug, as this is not musl-gcc nor poky-tiny specific bug but a generic busybox problem)
Comment 15 Ross Burton 2016-09-19 12:42:55 UTC
Fixed in oe-core a866a05e2c7d090a77aa6e95339c93e3592703a6.