Bug 6996 - cyclic symlinks in rootfs cause user-space qemu to infinite loop on startup
Summary: cyclic symlinks in rootfs cause user-space qemu to infinite loop on startup
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 1.6
Hardware: All Multiple
: Medium normal
Target Milestone: 2.2 M3
Assignee: Aníbal Limón
QA Contact:
URL: https://bugs.launchpad.net/qemu/+bug/...
Whiteboard:
Depends on:
Blocks:
 
Reported: 2014-11-24 15:52 UTC by Alexandre Tuleu
Modified: 2016-07-25 21:10 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
Custom recipe for xenomai inspired from meta-eldk (3.09 KB, application/octet-stream)
2014-11-24 15:52 UTC, Alexandre Tuleu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Tuleu 2014-11-24 15:52:16 UTC
Created attachment 2257 [details]
Custom recipe for xenomai inspired from meta-eldk

When building an image that install recipes that have cyclic symlink, the do_rootfs freeze the host system after qemu has eaten all virtual memory.

This is the case for the attached custom recipe, (a step in the attachement has been added to remove these cyclic links). xenomai want to install a header file hierarchy with several symlinks like those :

* /usr/xenomai/include/xenomai -> /usr/xenomai/include
* /usr/xenomai/include/asm-x86/xenomai -> /usr/xenomai/include/asm-x86
...

Without an ulimit, the rootfs will freeze the host system. If a large ulimit is set (ulimit -v 8000000), the postint_intercept scripts update_font_cache and update_pixbuf_cache are both segfault-ing after a few minutes. However it would mean that the same script would be run at first boot of the target system, maybe making the image not usable.

From the fontconfig changelog, this utility is since version 2.6.34 robust to recursive symlink. Maybe the yocto patch or the qemu wrapping are breaking this feature

The dirty patch at do_install of this custom recipe effectivelly solves the issue, and an image that would list package xenomai-dev will be build without issues

I see several issues :
* the postinst_intercept scripts should be robust to cyclic symlinks
* A ulimit should maybe be automatically set before calling qemu at postinst_intercept step, to avoid the host system to freeze.
Comment 1 Ross Burton 2015-03-10 16:39:22 UTC
I created a basic recipe that installs a circular loop and added it to core-image-sato, and with master do_rootfs works fine, which implies that either qemu or fontconfig (or both) are working correctly now.
Comment 2 Ross Burton 2015-03-26 19:37:16 UTC
I can't replicate this in fido (1.8) using a custom recipe to create a cyclic link.
I can replicate this in daisy (1.6) using udev-ptest as a cyclic link.
Dizzy (1.7) is building now.

I'm not sure what you mean by fontconfig 2.6.34, there isn't a fontconfig release of that name.
Comment 3 Ross Burton 2015-03-26 20:58:01 UTC
I take it back, I can replicate this with fido if I revert the udev fix.
Comment 4 Ross Burton 2015-03-26 21:03:35 UTC
Both fontconfig and gdk-pixbuf install postinstall hooks that spin when they hit the cyclic loop.
Comment 5 Ross Burton 2015-03-26 21:34:37 UTC
Aha, upstream bug report: https://bugs.launchpad.net/qemu/+bug/1245703
Comment 6 Ross Burton 2015-03-26 21:40:15 UTC
Marking as 1.9, this is too late to start meddling with qemu and there's workarounds in fido (which are currently being backported to 1.7).
Comment 7 Richard Purdie 2016-03-09 13:25:16 UTC
I suspect the easiest solution is to modify uilt/path.c in qemu such that it doesn't interate all paths at the start but does so "on demand". This would avoid it walking pieces of the tree it never uses. I have a patch which attempts to do this.
Comment 9 Ross Burton 2016-07-25 21:10:45 UTC
Marking as resolved as oe-core 9ac5017b3328a18561c2912edfda2d7d97c675f2 fixed it.