Bug 102316

Summary: Euro Truck Simulator 2 crashes when changing graphics settings with mesa 17.3.0, but not with 17.0.7
Product: Mesa Reporter: leozinho29_eu
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: danylo.piliaiev
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description leozinho29_eu 2017-08-20 04:33:16 UTC
Hi

In the game Euro Truck Simulator 2 version 1.28 it is not possible to change the graphics settings because when doing so the game crashes. On dmesg the following messages appear:

[ 6921.008079] eurotrucks2[7098]: segfault at 0 ip 0000000000a3ff90 sp 00007fff0c1028b0 error 4 in eurotrucks2[400000+1549000]

In multiple times the crash looks very similar:

[ 7016.877901] eurotrucks2[7503]: segfault at 0 ip 0000000000a3ff90 sp 00007ffe4a807860 error 4 in eurotrucks2[400000+1549000]
[ 9652.424350] eurotrucks2[6492]: segfault at 0 ip 0000000000a3ff90 sp 00007ffd508b7c60 error 4 in eurotrucks2[400000+1549000]

The game log may no be very useful here, but it is available in: https://pastebin.com/7m1SV1QN

Expected behavior: I am able to change graphics settings in the game.

Observed behavior: The game crashes when changing graphics settings.

While I have reported this problem to the game developers on their forum, I believe the problem is with mesa. I was using mesa version 17.3.0 from git (git-494f86bbe5 and a later version I built 30 minutes ago, which I uninstalled to test).

I am now using mesa version 17.0.7 from Xubuntu 17.04 amd64 and with this mesa version there is no crash when changing graphics settings. I am unsure if this is a regression or I have built mesa with some wrong configuration.

My system hardware:
Processor: Intel Core i3-6100U
Graphics Card: Intel HD Graphics 520
RAM: 8 GB

The configuration I use to build mesa:

./autogen.sh --prefix=/usr/local --with-vulkan-drivers="intel" --with-dri-drivers="i915 i965 swrast" --with-dri-driverdir=/usr/local/lib/dri --with-gallium-drivers="i915,svga,swrast" --enable-gles1 --enable-gles2 --enable-opencl --enable-va --enable-nine --enable-llvm --enable-xa --enable-osmesa --enable-shared-glapi --with-egl-platforms=x11,drm --enable-texture-float  --enable-gbm --enable-glx-tls  --enable-dri3

I build both 32-bit and 64-bit mesa. The configuration files I have are in /etc/profile.d and /etc/ld.so.conf.

Content from the file in /etc/profile.d/minhamesa.sh

mesa_installation_dir=/usr/local
LIBGL_DRIVERS_PATH=$mesa_installation_dir/lib/dri:/home/usuario/mesa/install32/lib/dri

export mesa_installation_dir
export LIBGL_DRIVERS_PATH

------------------------------------------

Content from the file in /etc/ld.so.conf/minhamesa32.conf

/home/usuario/mesa/install32/lib
/home/usuario/mesa/install32/lib/dri
/home/usuario/mesa/install32/lib/d3d
/home/usuario/mesa/install32/lib/gallium-pipe

------------------------------------------

The 32-bits mesa install is at the user folder and is owned by root.

As I have told before, I am unsure this is a regression, but the fact it works with 17.0.7 but not with 17.3.0 it is suspect.
Comment 1 leozinho29_eu 2017-08-20 05:23:45 UTC
I have built mesa 17.0.7 from git instead of the Xubuntu default and it hadn't this bug. From my tests using the same parameters to build:

17.3.0 - has the bug
17.2.0 - has the bug
17.1.6 - hasn't the bug
17.0.7 - hasn't the bug

So the bug exists in at least the mesa version 17.2.0, and 17.1.6 is not affected. 

PS.: Building mesa with a i3-6100U is slow.
Comment 2 Kenneth Graunke 2017-08-20 06:55:09 UTC
(In reply to leozinho29_eu from comment #1)
> PS.: Building mesa with a i3-6100U is slow.

You're actually building a lot of stuff you don't need.  This should build much faster:

./autogen.sh --with-dri-drivers="i965" --with-vulkan-drivers="intel" --with-dri-driverdir=/usr/local/lib/dri --prefix=/usr/local --sysconfdir=/etc --with-gallium-drivers="" --with-egl-platforms=x11,drm --enable-debug

Thanks for the bug report, we'll have to try and reproduce it and bisect.
Comment 3 Kenneth Graunke 2017-08-20 07:06:00 UTC
I can't reproduce this.  I just installed Euro Truck Simulator 2 from Steam, launched the game, and tried changing the graphical settings...enabling/disabling Sunshafts and Depth of Field...and it worked fine.  I also tried changing resolution...and that worked fine too.

Can you 'gdb attach' to the game and get a backtrace ('bt') when it crashes?
Comment 4 leozinho29_eu 2017-08-20 16:08:07 UTC
I hope I have done this correctly. This is what happened with mesa version 17.2.0 (git-cc8ae8842b):

(gdb) attach 17397
Anexando a process 17397
[New LWP 17398]
[New LWP 17399]
[New LWP 17400]
[New LWP 17401]
[New LWP 17402]
[New LWP 17403]
[New LWP 17406]
[New LWP 17407]
[New LWP 17408]
[New LWP 17409]
warning: Could not load shared library symbols for libsteam_api.so.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f458fd9bd8d in poll () at ../sysdeps/unix/syscall-template.S:84
84	../sysdeps/unix/syscall-template.S: Arquivo ou diretório não encontrado.
(gdb) continue
Continuando.
[Thread 0x7f4529ae3700 (LWP 17409) exited]
[New Thread 0x7f4529ae3700 (LWP 17451)]

Thread 1 "eurotrucks2" received signal SIGSEGV, Segmentation fault.
0x0000000000a3ff90 in ?? ()
(gdb) backtrace
#0  0x0000000000a3ff90 in ?? ()
#1  0x00000000008c6136 in ?? ()
#2  0x000000000092549b in ?? ()
#3  0x0000000000925c9e in ?? ()
#4  0x0000000000b25983 in ?? ()
#5  0x0000000000b19041 in ?? ()
#6  0x00000000008b8eab in ?? ()
#7  0x00000000008b909f in ?? ()
#8  0x0000000000b192f7 in ?? ()
#9  0x0000000000581995 in ?? ()
#10 0x00000000008c541c in ?? ()
#11 0x00000000008b8882 in ?? ()
#12 0x00000000004177a2 in ?? ()
#13 0x00007f458fcbf3f1 in __libc_start_main (main=0x4176e0, argc=1, argv=0x7ffefd376048, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffefd376038)
    at ../csu/libc-start.c:291
#14 0x000000000054d097 in ?? ()
Comment 5 leozinho29_eu 2017-09-25 17:50:43 UTC
Hi

I have updated mesa to 17.2.1 (git-d6d2b6b5ec) and this crash still happens, but now the backtrace had more information:

Thread 1 "eurotrucks2" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
58	../sysdeps/unix/sysv/linux/raise.c: Arquivo ou diretório não encontrado.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
#1  0x00007f0ce341837a in __GI_abort () at abort.c:89
#2  0x00007f0ce345a090 in __libc_message (do_abort=do_abort@entry=2, 
    fmt=fmt@entry=0x7f0ce3570000 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007f0ce3463c3a in malloc_printerr (ar_ptr=<optimized out>, ptr=<optimized out>, 
    str=0x7f0ce35700a0 "free(): corrupted unsorted chunks", action=3) at malloc.c:5048
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=<optimized out>) at malloc.c:3904
#5  0x00007f0ce3467d2c in __GI___libc_free (mem=mem@entry=0x3594420) at malloc.c:2984
#6  0x00007f0ce341b29d in __run_exit_handlers (status=1, listp=0x7f0ce37a25d8 <__exit_funcs>, 
    run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:92
#7  0x00007f0ce341b2ca in __GI_exit (status=<optimized out>) at exit.c:105
#8  0x00007f0ce3f18b58 in _XDefaultError () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#9  0x00007f0ce46584b6 in ?? () from /home/usuario/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so
#10 0x00007f0ce3f18c8d in _XError () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#11 0x00007f0ce3f15bb7 in ?? () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#12 0x00007f0ce3f16c8d in _XReply () from /usr/lib/x86_64-linux-gnu/libX11.so.6
#13 0x00007f0c973c6310 in XRRGetCrtcInfo () from /usr/lib/x86_64-linux-gnu/libXrandr.so.2
#14 0x00000000011015ef in ?? ()
#15 0x0000000000925d14 in ?? ()
#16 0x0000000000b19035 in ?? ()
#17 0x00000000008b8eab in ?? ()
#18 0x00000000008b909f in ?? ()
#19 0x0000000000b192f7 in ?? ()
#20 0x0000000000581995 in ?? ()
#21 0x00000000008c541c in ?? ()
#22 0x00000000008b8882 in ?? ()
#23 0x00000000004177a2 in ?? ()
#24 0x00007f0ce34013f1 in __libc_start_main (main=0x4176e0, argc=1, argv=0x7ffe7a8c2918, init=<optimized out>, 
    fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe7a8c2908) at ../csu/libc-start.c:291
#25 0x000000000054d097 in ?? ()
Comment 6 Andriy Khulap 2018-01-12 09:46:33 UTC
I am able to reproduce this issue on the following configuration:
Intel(R) HD Graphics 530 (Skylake GT2)  (0x191b)
(Dell Latitude E5470)
Ubuntu 16.04 Kernel 4.4.0
Mesa 17.4.0-devel (git-4f1e500)
Latest steam and Euro Truck Simulator 2 Demo

I'm stating the game, skipping tutorials, staring first drive.
Pressing escape->graphics options. Then clicking anywhere on graphics settings gauge causes the crash.

GDB backtrace looks the same as already reported:
Thread 1 "eurotrucks2" received signal SIGSEGV, Segmentation fault.
0x00000000009fadf0 in ?? ()
(gdb) bt full
#0  0x00000000009fadf0 in ?? ()
No symbol table info available.
#1  0x000000000088b7b7 in ?? ()
No symbol table info available.
#2  0x00000000008e9b4e in ?? ()
No symbol table info available.
#3  0x00000000008ea37e in ?? ()
No symbol table info available.
#4  0x0000000000ad4893 in ?? ()
No symbol table info available.
#5  0x0000000000ac8b81 in ?? ()
No symbol table info available.
#6  0x000000000087e5a3 in ?? ()
No symbol table info available.
#7  0x000000000087e79f in ?? ()
No symbol table info available.
#8  0x0000000000ac8e27 in ?? ()
No symbol table info available.
#9  0x00000000005787cd in ?? ()
No symbol table info available.
#10 0x000000000088aa7c in ?? ()
No symbol table info available.
#11 0x000000000087df2a in ?? ()
No symbol table info available.
#12 0x0000000000418292 in ?? ()
No symbol table info available.
#13 0x00007fa25d0ee830 in __libc_start_main (main=0x4181d0, argc=1, argv=0x7ffeb3702198, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7ffeb3702188) at ../csu/libc-start.c:291
        result = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -2814748865644266309, 5530590, 140731908891024, 0, 0, 2814015696906157243, 2861114662637206715}, 
              mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x1, 0x4181d0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 1}}}
        not_first_call = <optimized out>
#14 0x0000000000546407 in ?? ()
No symbol table info available.
(gdb) 

I will try the other mesa versions mentioned here to identify the "bad" commit.
Comment 7 Andriy Khulap 2018-01-12 11:21:42 UTC
Checked some other mesa versions:

17.1.6 (git-4f1e500) - OK
17.1.10 (git-4f1e500) - OK
17.2.0-rc1 (git-4f1e500) - crash
17.2.0 (git-4f1e500) - crash

Will try to bisect between 17.1.10 and 17.2.0-rc1
Comment 8 Andriy Khulap 2018-01-15 07:24:42 UTC
Bisected to:
6e06e281c6ee342276d087ed4ee4a442626e433a is the first bad commit
glx: add missing sRGB attribute check in fbconfigs_compatible()

Tested it by dropping it from the top of mesa git (42f421c aubinator: add support for aubinating memtrace aubs):
git revert 6e06e281c6ee342276d087ed4ee4a442626e433a
and the crash do not happening like in mesa-17.1.0 and older.

But it looks like code from that commit can't cause the crash, it may happening when processing "return False" from added macros.
Comment 9 Andriy Khulap 2018-01-17 14:15:12 UTC
When changing graphics settings, this game calls glXChooseFBConfig() function with the following attributes:
   tag=32785 val=1  GLX_RENDER_TYPE
   tag=32786 val=1  GLX_X_RENDERABLE
   tag=5     val=1  GLX_DOUBLEBUFFER
   tag=12    val=24 GLX_DEPTH_SIZE
   tag=13    val=8  GLX_STENCIL_SIZE
   tag=8     val=8  GLX_RED_SIZE
   tag=9     val=8  GLX_GREEN_SIZE
   tag=10    val=8  GLX_BLUE_SIZE
   tag=11    val=8  GLX_ALPHA_SIZE
   tag=8370  val=1  GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
glXGetFBConfigs() returns 88 possible configurations in my case, but they all not sRGB-cabable (.sRGBCapable=0). So they all considered incompatible and glXChooseFBConfig() returns NULL and zero list size.

Next, function glXChooseVisual() is called with the following attributes:
   tag=1    val=4  GLX_USE_GL
   tag=4    val=5  GLX_RGBA
   tag=5    val=12 GLX_DOUBLEBUFFER
   tag=12   val=24 GLX_DEPTH_SIZE
   tag=13   val=8  GLX_STENCIL_SIZE
   tag=8    val=8  GLX_RED_SIZE
   tag=9    val=8  GLX_GREEN_SIZE
   tag=10   val=8  GLX_BLUE_SIZE
   tag=11   val=8  GLX_ALPHA_SIZE
   tag=8370 val=0  GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT
With sRGBCapable=0 it returns valid XVisualInfo*:
   visualList=0xcb30d10
   visualList->visual=0x368bca0
   visualList->visualid=32
   visualList->screen=0
   visualList->depth=24
   visualList->class=4
   visualList->red_mask=ff0000
   visualList->green_mask=ff00
   visualList->blue_mask=ff
   visualList->colormap_size=256
   visualList->bits_per_rgb=8
But the game crashes after this.

Without the check from 6e06e281c6ee (MATCH_DONT_CARE(sRGBCapable);), the glXChooseFBConfig() function returns 14 compatible configurations and game operates normally.
Comment 10 Andriy Khulap 2018-03-23 10:33:57 UTC
I've tested this game on Ubuntu 18.04 beta and was unable to reproduce it with default mesa-18.0.0-rc4 (hardware was also Skylake GT, but 0x1916). The graphics settings were changed without any problems.

But I can't run this game with any other mesa version from git. Tried 17.3.6, latest master, even the same 18-0.0-rc4. Game changes desktop resolution to 1024x768 and don't run. Maybe Ubuntu 18.04 has some extra patches applied.

On another Skylake GT2 (0x191b) system I'm running Debian testing and it behaves like in previous test: 17.3.6, 18.0.0-rc4, 18.0.0-rc5 ... and they all require reverting of 6e06e281c6ee for proper game operation. 
With latest mesa master the game doesn't start exactly like 18.04 described above.
Comment 11 Tapani Pälli 2018-03-23 12:18:52 UTC
(In reply to Andriy Khulap from comment #10)
> I've tested this game on Ubuntu 18.04 beta and was unable to reproduce it
> with default mesa-18.0.0-rc4 (hardware was also Skylake GT, but 0x1916). The
> graphics settings were changed without any problems.
> 
> But I can't run this game with any other mesa version from git. Tried
> 17.3.6, latest master, even the same 18-0.0-rc4. Game changes desktop
> resolution to 1024x768 and don't run. Maybe Ubuntu 18.04 has some extra
> patches applied.
> 
> On another Skylake GT2 (0x191b) system I'm running Debian testing and it
> behaves like in previous test: 17.3.6, 18.0.0-rc4, 18.0.0-rc5 ... and they
> all require reverting of 6e06e281c6ee for proper game operation. 
> With latest mesa master the game doesn't start exactly like 18.04 described
> above.

Do these 2 different setups have different Xorg version? I have a feeling that this bug is about visual mismatch between Xorg server and Mesa.
Comment 12 Andriy Khulap 2018-03-26 09:16:54 UTC
The Xorg version is the same for both systems:
   X.Org X Server 1.19.6
   Release Date: 2017-12-20

Other info for Ubuntu 18.04 where I can switch graphics settings (no issues):
$ inxi -GCSx
System:    Host: ***** Kernel: 4.15.0-12-generic x86_64 bits: 64 gcc: 7.3.0
           Desktop: Gnome 3.28.0 (Gtk 3.22.28-1ubuntu3) Distro: Ubuntu Bionic Beaver (development branch)
CPU:       Dual core Intel Core i3-6006U (-MT-MCP-) arch: Skylake rev.3 cache: 3072 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 7968
           clock speeds: max: 2000 MHz 1: 500 MHz 2: 500 MHz 3: 500 MHz 4: 500 MHz
Graphics:  Card: Intel HD Graphics 520 bus-ID: 00:02.0
           Display Server: x11 (X.Org 1.19.6 ) driver: i915 Resolution: 1920x1080@60.01hz
           OpenGL: renderer: Mesa DRI Intel HD Graphics 520 (Skylake GT2)
           version: 4.5 Mesa 18.0.0-rc4 Direct Render: Yes



System where issue is present:
$ inxi -GCSx
System:    Host: ***** Kernel: 4.15.0-1-amd64 x86_64 bits: 64 gcc: 7.3.0
           Desktop: Xfce 4.12.4 (Gtk 2.24.31) Distro: Debian GNU/Linux buster/sid
CPU:       Quad core Intel Core i5-6440HQ (-MCP-) arch: Skylake-S rev.3 cache: 6144 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 20736
           clock speeds: max: 3500 MHz 1: 1092 MHz 2: 1543 MHz 3: 2187 MHz 4: 2137 MHz
Graphics:  Card: Intel HD Graphics 530 bus-ID: 00:02.0
           Display Server: x11 (X.Org 1.19.6 ) drivers: modesetting (unloaded: fbdev,vesa)
           Resolution: 1920x1080@60.05hz, 1920x1080@60.00hz
           OpenGL: renderer: Mesa DRI Intel HD Graphics 530 (Skylake GT2)
           version: 4.5 Mesa 17.3.6 (git-b3e5a3f35b) Direct Render: Yes
Comment 13 Danylo 2018-08-07 10:09:42 UTC
Tested Euro Truck Simulator 2 with newer Mesa and have no issues with next setup:

Ubuntu 18.04
Intel Core i5-6440HQ (Intel HD Graphics 530)
Mesa 18.1.3, 18.3.0-devel
X.Org 1.19.6
Kernel: 4.17.0

Game can be launched and played with any quality settings.
Comment 14 Denis 2018-08-07 11:14:54 UTC
Hi. Also want to add some information, according to Andrey's comment. I build mesa versions from source 17.3.9 and 18.0.0-rc4, on both of them game was launched. But - on 17.3.9 I reproduced crash, on 18.0.0-rc4 - didn't reproduce.
Also I checked latest git mesa, and also didn't reproduce bug. I would say, that this issue is not actual anymore.

My HW:

Distributive -> Ubuntu 16.04.5 LTS
Kernel version -> 4.15.0-29-generic
GPU -> Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake GT2)
Mesa version -> 3.0 Mesa 18.3.0-devel (git-3a9f628)
X.Org X Server 1.19.6

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.