https://bugs.freedesktop.org/show_bug.cgi?id=100242
Bug ID: 100242 Summary: radeon buffer allocation failure during startup of Factorio Product: Mesa Version: git Hardware: x86-64 (AMD64) OS: Linux (All) Status: NEW Severity: normal Priority: medium Component: Drivers/Gallium/r600 Assignee: dri-devel@lists.freedesktop.org Reporter: tnmailinglists@gmail.com QA Contact: dri-devel@lists.freedesktop.org
Created attachment 130277 --> https://bugs.freedesktop.org/attachment.cgi?id=130277&action=edit terminal output when running the executable
The game Factorio crashes during startup with the following message printed on the CLI: radeon: Failed to allocate a buffer: radeon: size : 268435456 bytes radeon: alignment : 16384 bytes radeon: domains : 4 radeon: flags : 20
The crash occurs during the pre-game loading procedure, before reaching the main menu, at the same spot every time. I'm on Lubuntu 16.10 using the up-to-date drivers provided by https://launchpad.net/~oibaf/+archive/ubuntu/graphics-drivers , my GPU is a Radeon HD 4670 with AGP. I believe this is a driver issue since the game starts up normally with 16.10's default drivers (12.0.6). I unfortunately cannot provide a specific date or build for when this behavior started occurring, but it has been happening for several months.
Of note is that the demo version provided by the developer on their website does not have this problem and starts up fine.
Attached are the terminal output, an strace and a gdb bt log.
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #1 from tnmailinglists@gmail.com --- Created attachment 130278 --> https://bugs.freedesktop.org/attachment.cgi?id=130278&action=edit strace
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #2 from tnmailinglists@gmail.com --- Created attachment 130279 --> https://bugs.freedesktop.org/attachment.cgi?id=130279&action=edit gdb bt
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #3 from tnmailinglists@gmail.com --- I retested the game with mesa 12.0.6 and xserver-xorg-video-radeon 1:7.7.1 (the current versions for default Lubuntu 16.10) and noticed that while the game doesn't crash, it still produces buffer allocation failures during startup:
2.969 Initial atlas bitmap size is 8192 radeon: Failed to allocate a buffer: radeon: size : 268435456 bytes radeon: alignment : 16384 bytes radeon: domains : 4 radeon: flags : 20 radeon: Failed to allocate a buffer: radeon: size : 268435456 bytes radeon: alignment : 16384 bytes radeon: domains : 4 radeon: flags : 20 radeon: Failed to allocate a buffer: radeon: size : 268435456 bytes radeon: alignment : 16384 bytes radeon: domains : 4 radeon: flags : 20 radeon: Failed to allocate a buffer: radeon: size : 268435456 bytes radeon: alignment : 16384 bytes radeon: domains : 4 radeon: flags : 20 3.029 Couldn't create atlas bitmap (size 8192x8182), will try again 3.094 Created atlas bitmap 4096x4096
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #4 from Christian König deathsimple@vodafone.de --- The maximum size for allocations in VRAM on radeon are usually 256MB minus pinned system resources like GART.
The game tries to allocate something which is 256MB in size, so that won't fit.
Either the driver tries to allocate a temporary buffer which is way to large or the game tries to allocate a texture which is way to large.
https://bugs.freedesktop.org/show_bug.cgi?id=100242
Michel Dänzer michel@daenzer.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |NOTOURBUG
--- Comment #5 from Michel Dänzer michel@daenzer.net --- (In reply to tnmailinglists from comment #3)
3.029 Couldn't create atlas bitmap (size 8192x8182), will try again 3.094 Created atlas bitmap 4096x4096
Looks like the game now gracefully handles the failure to allocate an 8192x8192 (= 256MB) atlas texture and falls back to a 4096x4096 one. The crash before was probably a game bug.
https://bugs.freedesktop.org/show_bug.cgi?id=100242
tnmailinglists@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|NOTOURBUG |--- Status|RESOLVED |REOPENED
--- Comment #6 from tnmailinglists@gmail.com --- (In reply to Michel Dänzer from comment #5)
(In reply to tnmailinglists from comment #3)
3.029 Couldn't create atlas bitmap (size 8192x8182), will try again 3.094 Created atlas bitmap 4096x4096
Looks like the game now gracefully handles the failure to allocate an 8192x8192 (= 256MB) atlas texture and falls back to a 4096x4096 one. The crash before was probably a game bug.
I think you are misreading my comment, I was using an older stable version of mesa there to make sure that it still worked as described in the original post. I did not change the game version. It does not crash with mesa 12.0.6 and radeon 1:7.7.1, but it does crash on mesa 17.1 git with radeon 1:7.9.0. It could still be a game bug, but I'd guess something has changed in the way the driver does buffer allocation if it crashes in one case but not the other with the same game executable.
I've reopened for now since the crash still happens on git mesa, feel free to close again if I misunderstood what you meant.
https://bugs.freedesktop.org/show_bug.cgi?id=100242
Michel Dänzer michel@daenzer.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #130279|text/x-log |text/plain mime type| |
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #7 from Michel Dänzer michel@daenzer.net --- I indeed misread your comment, sorry. Can you bisect Mesa?
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #8 from tnmailinglists@gmail.com --- I managed to bisect mesa and got this result:
https://cgit.freedesktop.org/mesa/mesa/commit/?id=fb827c055cb1bdd2b18d0687c0... is the first bad commit commit fb827c055cb1bdd2b18d0687c06c56b537d805f3 Author: Nicolai Hähnle nicolai.haehnle@amd.com Date: Mon Sep 12 12:19:47 2016 +0200
winsys/radeon: enable buffer allocation from slabs
Only enable for chips with GPUVM, because older driver paths do not take the required offset into account.
Reviewed-by: Marek Olšák marek.olsak@amd.com
:040000 040000 4e1327d4b72890178a2057d2341971001f2de54d d162404a219307e5f6cda1009b864e66f23f4e63 M src
I have also noticed that after a recent update the game now gives some more information, so when it does run like described in comment #3, it now also tells me that it detected an error by adding the following line right after the four driver error blocks:
2.321 glTexImage2D for format ARGB_8888, size 8192x8185 failed (GL_OUT_OF_MEMORY)
https://bugs.freedesktop.org/show_bug.cgi?id=100242
Michel Dänzer michel@daenzer.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nhaehnle@gmail.com
--- Comment #9 from Michel Dänzer michel@daenzer.net --- Looks like Nicolai's change caused a regression for non-VM GPUs.
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #10 from Nicolai Hähnle nhaehnle@gmail.com --- Created attachment 132275 --> https://bugs.freedesktop.org/attachment.cgi?id=132275&action=edit likely fix
It is a silly bug. The attached patch should fix the crash you're seeing. Please let me know if the game runs fine with this or if there is any other crash you're running into. Thanks!
https://bugs.freedesktop.org/show_bug.cgi?id=100242
--- Comment #11 from tnmailinglists@gmail.com --- The game starts up fine without a crash now and handles the out of memory error gracefully like before. Thanks!
https://bugs.freedesktop.org/show_bug.cgi?id=100242
Nicolai Hähnle nhaehnle@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|REOPENED |RESOLVED
--- Comment #12 from Nicolai Hähnle nhaehnle@gmail.com --- Thanks for testing again. The fix is in Mesa master, commit b0b4b5e8f7a25dd11c1662d339d68c9733e9b2dc.
dri-devel@lists.freedesktop.org