Bug 95329 - Metro 2033 Redux benchmark fails to start
Summary: Metro 2033 Redux benchmark fails to start
Status: RESOLVED NOTOURBUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/radeonsi (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-09 19:28 UTC by Jan Ziak (http://atom-symbol.net)
Modified: 2018-07-10 23:11 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
user.cfg (4.03 KB, text/plain)
2016-05-09 19:29 UTC, Jan Ziak (http://atom-symbol.net)
Details

Description Jan Ziak (http://atom-symbol.net) 2016-05-09 19:28:42 UTC
Mesa: 11.3.0-devel (git-57763ee)
GPU: R9 390 (dynamic power management: disabled)
Linux kernel: 4.5.0
Kernel module: radeon

Steps to reproduce the issue:

1) cd ".steam/root/steamapps/common/Metro 2033 Redux"
2) mv metro metro.bin
3) ln -s benchmark.sh metro
4) Edit benchmark.sh and replace "./metro" with "./metro.bin"
5) Copy the file "user.cfg" (attached to this bug report) to directory "110000106d2b5d5"
6) Start the Steam client from command-line
7) Start Metro 2033 Redux from the Steam client

Segmentation fault (core dumped) 
./metro.bin -benchmark benchmarks\\benchmark33 -bench_runs 1 -output_file benchmark.log -close_on_finish

Notes:
- Running "gdb metro.bin core" does not provide useful information
- AMD drivers (fglrx) are working OK
- Step 5 is maybe optional, but I haven't verified this

Running "valgrind --tool=callgrind" for about an hour seems to indicate that the issue may be linked to very slow shader compilation, but this is inconclusive. AMD drivers (fglrx) start the benchmark much faster.
Comment 1 Jan Ziak (http://atom-symbol.net) 2016-05-09 19:29:56 UTC
Created attachment 123583 [details]
user.cfg
Comment 2 Jan Ziak (http://atom-symbol.net) 2016-05-11 12:26:51 UTC
The game itself (excluding the benchmark) runs OK with Mesa.
Comment 3 Jan Ziak (http://atom-symbol.net) 2016-05-17 12:03:13 UTC
The cause of the issue is in metro.bin, not in Mesa. Found via running "valgrind benchmark.sh".

The following code fixes the issue:

$ cat posix_memalign.c
#include <errno.h>
#include <malloc.h>
#include <stdlib.h>
#include <strings.h>

int posix_memalign(void **memptr, size_t alignment, size_t size) {
        if(alignment < 32) {
                alignment = 32;  // Optional. Might boost memcpy().
        }
        size *= 2;       // Required
        void *p = memalign(alignment, size);
        if(!p && size) {
                return ENOMEM;
        }
        bzero(p, size);  // Optional
        *memptr = p;
        return 0;
}

$ gcc -m32 -shared -fPIC -O2 -g -Wall -Werror -std=c99 -o posix_memalign32.so posix_memalign.c
$ gcc -m64 -shared -fPIC -O2 -g -Wall -Werror -std=c99 -o posix_memalign64.so posix_memalign.c
$ export LD_PRELOAD="$PWD/posix_memalign32.so:$PWD/posix_memalign64.so:$LD_PRELOAD"
$ .../Metro 2033 Redux/benchmark.sh
Comment 4 Jan Ziak (http://atom-symbol.net) 2018-07-10 17:18:59 UTC
Still reproducible in July 2018.
Comment 5 Alexander Tsoy 2018-07-10 23:11:52 UTC
Another workaround is possible with newer glibc:

GLIBC_TUNABLES=glibc.malloc.check=3 ./benchmark.sh


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.