-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug][Solved] Mono.Unix.UnixIOException: Resource temporarily unavailable on Arch Linux after Util.Invoke and long chain of runtime calls #3343
Comments
This comment has been minimized.
This comment has been minimized.
@HebaruSan Pastebin seems to be the standard but sure, edited. |
Also, it seems only to be the problem when downloading 5+ mods at once. |
This looks like a problem with the Mono install rather than a CKAN code issue. A fellow Arch user may know what sorts of things to check; I'll see if there are any on the Discord. |
Here's a possibility. It looks like some Arch users had problems with applications being able to create threads, and CKAN creates one thread for each download: https://bugs.archlinux.org/task/47662 We had an AUR user report this on the Discord, but they didn't really figure anything out about it: Make sure your Mono can create threads as needed and see if there are any similar known issues with threading on your version of Arch. |
Ok, seems that raising the open files limit to 10240 and stack size to 32768 enabled it to work, thank you for pointing me in right direction! I will test it some more and then close the issue. Fix note: |
Cool! If you do find a good solution, would you mind updating the wiki? I can copy/paste from here to there if need be, but it would be better if the person investigating the issue was the one doing the editing: https://github.com/KSP-CKAN/CKAN/wiki/Installing-CKAN-on-Arch |
Sure! Probably not today but i can also write in permanent solution :) . Also all seems to work so closing! |
This bug is unrelated to Arch Linux proper, this is an upstream bug presents in mono version 6.12.0.86 and upward. The fact that it only affects Arch Linux for now because Arch is bleeding edge and uses the latest mono version while other distributions tend to use older versions is only tangential. The "fix" proposed by BlazingPL unfortunately doesn't and cannot work. The bug is unrelated to the number of open files or the size of the stack (or any other ulimit for that matter). The bug happens because a pipe buffer get full and the exception triggered by this condition is erroneously not caught. As far as I know there is no way to control the size of pipes' buffers, so we cannot prevent the exception. If you want to know more see the mono pull request that fix this bug: mono/mono#21136. In the mean time, while the pull request is being reviewed, the only solution is to use a mono version older than 6.12.0.86 or build a custom version with the patch of mono's pull request 21136 included. |
I have mono 6.12.0.147 from mono's preview repo installed on my Kubuntu machine, and am not encountering this error. So there must be another unknown that influences whether this bug is triggered or not (?) In any case, thanks for posting here and shedding some light onto this elusive bug. And confirming that is's indeed not something we messed up 😄 |
The bug is indeed threading-related. I don't know a lot about mono's internals but they use a pipe to enable communication between the main UI thread and other threads. When CKAN downloads a lot of mods at once, each downloader thread regularly reports its progress to the main UI thread which causes the mono framework to send a message to the main UI thread by writing to this pipe. If the downloader threads are too numerous or the main UI thread is, for some reason, not scheduled often enough to read the pipe, the buffer of the pipe will fill up. This causes the Mono.Unix.UnixIOException which is, due to a bug in mono, currently not caught correctly and makes CKAN crash. Therefore the bug is intermittent as it depends on how many threads there is, how they are scheduled, etc... The first time I used CKAN on mono 6.12.0.122 I encountered it immediately and it happened each time I tried downloading mods. Later on, I wanted to reproduce the bug to get the stack trace but I had difficulties making it happen again and it took some tries to happen again. Also note the bug (mostly) only appears when downloading multiple mods at once. If your download cache contains a lot of already downloaded mods, CKAN might not have to download any mods or not enough for parallel download to trigger. If you want to reproduce the bug on Kubuntu:
Now, it might be the case that the conditions for the bug to happen depend on a lot of things: kernel version, X.org version, window manager, etc... Still the bug lies in mono and should (I hope) be corrected soon. |
This comment has been minimized.
This comment has been minimized.
Wow, thanks for this detailed explanation!
|
Oh I see, I'm not familiar with CKAN's implementation indeed. Then if I understand correctly, the bug doesn't happen because the downloader threads are not reporting their progresses to the main UI thread, thus not writing to the communication pipe, or at least not as frequently as in the full GUI ?
Implementing either of these two solutions should indeed fix the problem in 99% of cases. However, the remaining 1% might cause problems. Now, keeping in mind this is only a temporary solution while waiting for the mono fix, this should render the bug rare enough for CKAN to be perfectly usable.
I don't know if it's possible to catch Mono generated exceptions in user code but it's probably the case. If it is, this will for sure fix the problem but I think it carries the risk of catching other exceptions that shouldn't be caught. |
ConsoleUI doesn't use anything from the |
This is currently closed, but I've been having the issue on Arch 6.0.6 and KDE plasma, and the command mentioned didn't work (maybe bc zsh?). Regardless, I have found a pretty easy solution: for whatever reason, installing the mods through CLI just... works. I don't even know how that is, or how the code is different, but it's really weird. |
Background
Have you made any manual changes to your GameData folder (i.e., not via CKAN)?
Problem
Crash when downloading multiple mods at once.
Solution
ulimit -s 32768
ulimit -n 10240
did the trick, but it only works in current bash session (you need to launch ckan from terminal after adjusting limits).
For permanent solution you need to change /etc/security/limits.conf
The text was updated successfully, but these errors were encountered: