Repository navigation
Description
-
Your Windows build number: Microsoft Windows [Version 10.0.16299.19]
(WSL Ubuntu fresh install from store) -
What you're doing and what's happening:
Build instructions for the LuneOS system are here: http://webos-ports.org/wiki/Build_for_Tenderloin
Error text:
ERROR: linux-libc-headers-4.10-r0 do_package: Error executing a python function in exec_python_func() autogenerated:
The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
0001:
*** 0002:sstate_task_postfunc(d)
0003:
File: '/home/eric/build-lune/webos-ports-env/webos-ports/openembedded-core/meta/classes/sstate.bbclass', lineno: 702, function: sstate_task_postfunc
0698:
0699: omask = os.umask(0o002)
0700: if omask != 0o002:
0701: bb.note("Using umask 0o002 (not %0o) for sstate packaging" % omask)
*** 0702: sstate_package(shared_state, d)
0703: os.umask(omask)
0704:
0705: sstateinst = d.getVar("SSTATE_INSTDIR")
0706: d.setVar('SSTATE_FIXMEDIR', shared_state['fixmedir'])
File: '/home/eric/build-lune/webos-ports-env/webos-ports/openembedded-core/meta/classes/sstate.bbclass', lineno: 624, function: sstate_package
0620: for plain in ss['plaindirs']:
0621: pdir = plain.replace(workdir, sstatebuild)
0622: bb.utils.mkdirhier(plain)
0623: bb.utils.mkdirhier(pdir)
*** 0624: os.rename(plain, pdir)
0625:
0626: d.setVar('SSTATE_BUILDDIR', sstatebuild)
0627: d.setVar('SSTATE_PKG', sstatepkg)
0628:
Exception: PermissionError: [Errno 13] Permission denied: '/home/eric/build-lune/webos-ports-env/webos-ports/tmp-glibc/work/armv7ahf-neon-webos-linux-gnueabi/linux-libc-headers/4.10-r0/package' -> '/home/eric/build-lune/webos-ports-env/webos-ports/tmp-glibc/work/armv7ahf-neon-webos-linux-gnueabi/linux-libc-headers/4.10-r0/sstate-build-package//package'
ERROR: linux-libc-headers-4.10-r0 do_package: Function failed: sstate_task_postfunc
ERROR: Logfile of failure stored in: /home/eric/build-lune/webos-ports-env/webos-ports/tmp-glibc/work/armv7ahf-neon-webos-linux-gnueabi/linux-libc-headers/4.10-r0/temp/log.do_package.26018
ERROR: Task (/home/eric/build-lune/webos-ports-env/webos-ports/openembedded-core/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.10.bb:do_package) failed with exit code '1'
This seems to be some kind of permissions error, but I'm not sure what kind of permissions error. This does not occur when following identical instructions on an actual Ubuntu system running 16.04.
This occurs a couple of hours into a system build on my laptop, approximately task #478.
I am not intimately familiar with the OE build system, so advice for tracking down any further specifics would be helpful. I did notice the double "/" on the pathname at the end, the last time I tried to run this, and I attempted to fix that, but it had no effect on the overall outcome. I also tested that double // in paths work correctly, normally, and they seem to.
Building on DrvFS results in a hung process very early in the build process, not sure how to diagnose.
-
What should be happening:
it shouldn't error here, and should complete the OS build. -
Strace of the failing command: I've got a 290MB strace, I could use some direction on how to trim it down specifically to an area that is relevant to the problem
Activity
bitcrazed commentedon Nov 14, 2017
Hey Eric. Thanks for filing, tho' in future, please do complete the issue template - your issue above omits requested info:
Please also attach the failure logfile noted at the end of your error dump above.
And since this looks like a permissions issue, please also include a long file listing (inc. permissions) of the offending
'/home/eric/build-lune/webos-ports-env/webos-ports/tmp-glibc/work/armv7ahf-neon-webos-linux-gnueabi/linux-libc-headers/4.10-r0/package' -> '/home/eric/build-lune/webos-ports-env/webos-ports/tmp-glibc/work/armv7ahf-neon-webos-linux-gnueabi/linux-libc-headers/4.10-r0/sstate-build-package//package'Thanks - appreciate your help diagnosing this issue.
ericblade commentedon Nov 14, 2017
OK, so, it's not able to create the last bit there -- .../sstate-build-package//package. Paste of results of ls -al coming
ls -al output for requested files/dirs:
ericblade commentedon Nov 14, 2017
strace.zip
Attached zip of strace. Please let me know if I can be of any further assistance.
therealkenc commentedon Nov 14, 2017
aka
aka
#1529 #2243 #1726 #640 (message) et al
ericblade commentedon Nov 15, 2017
Thanks for the super quick find, therealkenc . So that seems to indicate that it's not something that will be going away anytime in the near future? So, I guess, there's a question involved -- what can be done to get around the problem? Clearly this is happening to a number of other things, so it seems like having a general idea for how to change some things to not encounter this problem would be a good course of action, and I'd be happy to help in any way I can.
(i wonder if my idea of getting loopback device + ext fs would be a way to get 100% fs compatibility...)
therealkenc commentedon Nov 15, 2017
I've been thinking about that too since I posted #1529 and this turned out to be the cause of my #640 grief. Seems to me that with effort some cases (perhaps
apt) could be worked around. While there are a bunch of dupes accumulating here, it isn't causing userspace to completely fall over. POSIX rename would have been by necessity addressed ages ago if it was a super common case.Other than fd caching scenarios like #1529, I speculate (without any evidence) that the handles sometimes aren't being held open for any particular reason. It is just that no one even thinks about it on Real Linux because it isn't a problem you'd worry about. Maybe they're even benign handle leaks. A strategic
close()might solve a lot of scenarios.Or might not. It might take a wholesale refactoring, or be (practically speaking) impossible because the fd is open for a good reason. I have not looked at your specific fail closely.
therealkenc commentedon Nov 15, 2017
Also before you do anything else, run the thing as root just to make absolutely sure we're talking about the open directory handle problem and not something else. [Can't be too careful.]
ericblade commentedon Nov 15, 2017
I'm not at all familiar with the python code that the problem is occurring in, though the number of times I see "python" in the issues that you've linked does make me wonder if there's something weird in python land. But I'll have a look at it and see if I see anything obvious as to if it might be unintentionally holding a file open before doing a move. Or is it a different process entirely that is holding a file inside the directory open, then python tries to move it? There shouldn't be other things occurring in there, but perhaps something is being a little sticky -- like in releases of Win8 when you'd have to wait minutes sometimes for files to be unlocked after a program had opened them, before you could delete.
I'm pretty sure OE will absolutely 100% refuse to run as root, but I'll try it tomorrow anyway. At least knowing the root cause of the problem (file somewhere in tree held open while a rename/move occurs) might allow me to cast a critical eye on it and find something.
derekyu56 commentedon Nov 19, 2017
My yocto rocko build in WSL was also hit by this bug. Would appreciate suggestion on how to get around it. I tried run as root (by disable sanity in sanity.conf) and still got hit with the bug.
therealkenc commentedon Nov 24, 2017
That's basically the litmus test. If you get
EACCESas root the problem is #1529.ericblade commentedon Nov 24, 2017
hey derekyu56 are you having the same problem in the same package? others are reporting that different kinds of builds (different distros, i don't recall which ones i read, but there were some people on the OE mailing list talking about it) are working, or different kinds of errors, it seems .. but i think it might be something specific to the linux-libc-headers recipe, or it's build/package process . . . i still haven't had time to go and open it up and check to see if there's anything obvious.
derekyu56 commentedon Nov 24, 2017
Yes, It is the same package with a different version:
ERROR: linux-libc-headers-4.12-r0 do_package: Error executing a python function in exec_python_func()
ericblade commentedon Nov 24, 2017
Thanks derekyu56 gives me some insight that it might be package specific. I have taken a very brief look at the python script, and I didn't see anything that just stuck out at me like a sore thumb -- I'm starting to suspect that Linux Python in general can be problematic in WSL, based on the number of tickets that therealkenc mentioned that also mention Python in them. I just had a thought -- I wonder if the script's current working directory happens to be the directory that it's trying to move. Anyway, that's just speculation without real data to go on.
What I think I want to do next, when I have time, unless someone else gets to it before me (which is entirely possible, given my real serious lack of time to do personal projects right now) ..
in local.conf:
then do a strace bitbake linux-libc-headers, and then go analyzing it to see if i can see what is being held open. I think first, though, i'll go and print the CWD at the point of failure.
20 remaining items
therealkenc commentedon Nov 27, 2017
Maybe (spitballing because I haven't thought about it hard enough)
rename()should returnEBUSYinstead ofEACCESso we can identify cases where we know lack of posix directory rename is the cause. Just in the interim while a complete fix is worked out. If that is doable, we can just grep for the error instead of playing "find the open handle".ericblade commentedon Nov 28, 2017
ok, i think i want to know how you figured that out .. and then i think i don't want to know because it's probably crazy. :-)
so, just a few lines under the line you point out (line 612749)
There is (line 612771)
According to stackoverflow, this sets a "close-on-exec" flag, which causes the file descriptor to "be automatically (and atomically) closed when any of the exec family functions succeed".
Then the rename fails at line 714814.
So, 21 is a duplicate of fd 6, line 612747?
6 appears to be line 612733?
So.. it looks like that is a handle to ....-r0/psuedo/ not -r0/package/ ?
Is CLOEXEC not working or not implemented? Are no exec() calls being executed between here and there? Are the exec() calls not entirely implemented?
(edit: i had originally pinpointed FD 6 to a different file entirely, changed the last of this text quite a bit after I realized I needed to be at a different fd 6)
therealkenc commentedon Nov 28, 2017
Gold star for tenacity on this one 🌟. I think you might be onto something. I saw the
fcntl(21, F_SETFD, FD_CLOEXEC)but convinced myself it didn't matter. I forgot the kids.....Line 685930:
Is there any chance you can test this on Insider 17046? It could be that
FD_CLOEXECisn't working. But I have another theory...FD_CLOEXECworks, but doesn't get a chance to work. Because #1878 (message). Thatclone()call should have blocked process 31182 until 31196 exits. But on your WSL build (FCU), it won't. If therename()in 31182 gets to the fd first -- boom. That would explain a lot about your shove threads down the machine's throat test too.Gotta say, if that does turn out to be the problem, getting from a
CLONE_VMmisbehaviour to aEACCESfail was a long bloody bridge to walk.therealkenc commentedon Nov 28, 2017
Couple of final data points for the night. The good news is
FD_CLOEXECworks as advertised on WSL; I checked 'cause curious. This would be true in FCU or Insiders.The bad news in doing the cursory test case, it looks like my first impression about that
fcntl(21, F_SETFD, FD_CLOEXEC)is probably right. It doesn't matter. I set up a test case with what amounts to the same sequence of events and the fd is open, on both Real Linux and WSL.[edit Below is total nonsense because I failed to register that there is no
CLONE_VFORKflag]But that doesn't mean it doesn't get closed by bitbake though some means I missed. That
clone()I cited will behave differently on 17046, which could explain racey-like behaviour. The only way to know for sure is to try. But if I were a betting person, the smart money is still on a vanilla open handle problem in PID 31182.[end nonsense]
ericblade commentedon Nov 28, 2017
Can you tell me if I was incorrect about the file handle appearing to point to a different directory than the one that it is failing to move?
I don't currently have a machine on Insiders (the one that was got bit by the "does not boot on AMD devices" bug a few releases back, and had to be restored, and is now in use by someone else :| ) but I can probably get there.
The race-condition idea turned out to be a non-starter -- because I had enabled such high amounts of parallelization, the failing tasks got bumped far to the back of the queue, instead of happening in the normal order that they go in, where you usually see all of the tasks for a specific package complete at once -- it was trying to do as much fetching and building as it could, and saving the packaging steps for later, or something like that.
On the bright side, I did just remember that it should be possible to just run the failing step on it's own, and maybe I can strace from that, saving hundreds of thousands of lines maybe.
jstarks commentedon Nov 28, 2017
therealkenc Only CLONE_VFORK would cause 31182 to wait for 31196 to exit, and that wasn't included. RCU supports the included set of clone flags perfectly (CLONE_VM doesn't work by itself, but CLONE_VM | CLONE_THREAD works fine).
therealkenc commentedon Nov 28, 2017
John Starks (@jstarks)
Dammit, my head saw a
CLONE_VFORKin there (probably because I wanted there to be one) and clearly there isn't 🙄. Thanks.Eric Blade (@ericblade)
You can pull out the processes with grep.
grep -E "^31182" bitbake-strace.txt. You can alsogrepfor "clone(" in that output to find the kids to pull out. That's the secret sauce you were asking about. But don't. This one is pretty much "done".ericblade commentedon Nov 28, 2017
So.. should I try on the Insider build? I'm still slightly confused as to the exact source of the problem -- i'm trying to find out which file is open, so that I might have a hope of working around the problem somewhere in one of the bitbake classes or recipe, now that i've narrowed it down to a common set of recipes that all have similar characteristics, there is probably? something that should be closing the open handle, but that isn't happening because of something in common among these recipes.
That's why I was trying to track down which file is actually open, which lead me to the handle at -r0/psuedo instead of -r0/package .. which must be incorrect, though, since the open handle that is blocking the rename would have to be in the directory tree being moved, and -r0/psuedo is not in -r0/package
therealkenc commentedon Nov 28, 2017
[edit with re-think]
Personally I wouldn't. #1878 is not going to change anything.
Okay I see what you mean now. You could put a big sleep in the Python code after catching the error, and then look at
/procto see what handles are open. But you are probably going to find "oh yeah that". Effort.ericblade commentedon Nov 28, 2017
well, i'm interested in putting the effort in to figure it out, so i can either post a workaround (fixing the recipes), or we can absolutely determine that there's not another bug hiding. My Linux builder is no longer supported in real Linux, so I'm itching to get rid of it :-)
Where do I look in /proc ? and I'd guess I probably need to compare that to another strace run to see what the handles actually point to?
therealkenc commentedon Nov 29, 2017
ls -l /proc/<pid>/fdfor the process that is running. You can get all the PIDs that are active at the point you sleep withpstree -p. You can have the activestraceoutput file open in Sublime or similar to see what is going on as well. Or if you want to go hard, launch or attach the thing undergdb, break with crtrl-c at the sleep, and use thefilescommand. That's a couple of common approaches, but there's other tools out there as well. If you are doing a deep dive you might want to contact whoever maintains bitbake, because people who live-and-breath the code often (but not always) can tell you "oh, that's <reason>" if they are given a little background information on what's going wrong.[edit] There's gotta be an idiomatic way of finding the open file handles in Python too, but I wouldn't know.
therealkenc commentedon Jan 28, 2018
Duping into #1529. If 1529 flips status and building LuneOS still fails, open a new issue to that effect and we can take another run at it.
ericblade commentedon Dec 3, 2018
I guess I come back to this about once a year, give or take. :-D I wanted to see if newest Windows release (1809) had made any headway on this, so I dug it out again. Stops in exactly the same spots, same packages (linux-libc-headers and base-files). SO, I finally opened up the code that was failing, and swapped out the python "os.rename" call to a "shutil.copy" call, and it has moved from being about 5% successful before failure, to about 15%, and still running without a failure, so far. IF I don't run out of disk space (i haven't attempted any of the hacks to move WSL to non-boot-disk yet), it's looking good. . . but will take several hours to complete. (in WSL it's moving at a much slower clip than my native Linux box, which is slower, has less memory, and only has a spinning disk.... but it's probably due to the sheer volume of disk access, which we know is a bit slow in WSL)
therealkenc commentedon Apr 9, 2019
Eric Blade (@ericblade)
Nah, nothing new on the underlying problem.
As a time sink you might take a try at running the LuneOS build under the recently posted fuzzyTew/nodejswsl. His work-around is aimed at NodeJS scenarios, but assuming your open handle is transient (and I think it might be) it has a better than nothing chance of working for you. The hook is doing a sleep/retry along the lines of what I was suggesting back in November 2017, only lower down so you don't actually have to patch the Python code.