Software renderer crashes on Linux

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Software renderer crashes on Linux

Post by _mental_ »

Spoiler: Disassembly from the start of OpenGLSWFrameBuffer::OpenGLPal::Update()
Crash location is marked with =>

The result of r13+r9*1+0x0 (or simply r13+r9) is 0x1848193.
I believe it must be 16-bytes aligned to work.
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Software renderer crashes on Linux

Post by Edward-san »

Can you recompile in Release mode and adding '-DNO_STRIP=ON -DCMAKE_CXX_FLAGS=-g3 -DCMAKE_C_FLAGS=-g3'?
dpJudas
 
 
Posts: 3174
Joined: Sat May 28, 2016 1:01 pm

Re: Software renderer crashes on Linux

Post by dpJudas »

_mental_ wrote:The result of r13+r9*1+0x0 (or simply r13+r9) is 0x1848193.
I believe it must be 16-bytes aligned to work.
Hmm, yes, that instruction must use 16-byte aligned addresses to work.

Here's another guy having a similar type of crash: http://pzemtsov.github.io/2016/11/06/bu ... n-x86.html. The compiler assumes that any uint32_t is 4 byte aligned. When it generates the SSE optimized code, it makes sure it is 16-byte aligned, but only if the original assumption that it was already 4 byte aligned is correct.

Could it be that one of our pointers are not properly dword aligned?

Edit: I found this information about glMapBuffer: "Alignment of the returned pointer is guaranteed only if the version of the GL version is 4.2 or greater." So we could very well have an alignment issue at this spot.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Software renderer crashes on Linux

Post by _mental_ »

I had several issues with GCC code generation involving SSE instructions: broken auto-vectorization, broken alignment even for l-values, invalid transformation of intrinsics to instructions, ... Their Bugzilla is full of similar "success stories".

By the way, I tested in VM without hardware acceleration, it was Mesa3D LLVMpipe driver.
AFAIK it's quite close to spec so I hope it was the same crash as in OP.
User avatar
Rachael
Posts: 13964
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Software renderer crashes on Linux

Post by Rachael »

Should we pass -DNO_SSE if CMake detects it is using GCC by default, for now, until GCC gets a chance to fix those issues? And then recommend officially switching to Clang if someone wants a proper executable with the intrinsics enabled?
dpJudas
 
 
Posts: 3174
Joined: Sat May 28, 2016 1:01 pm

Re: Software renderer crashes on Linux

Post by dpJudas »

It would probably be better to specify the flags disabling the optimization passes that is causing the problem rather than try disable SSE completely. The software renderer runs at half its normal speed if you define NO_SSE.
User avatar
Rachael
Posts: 13964
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Software renderer crashes on Linux

Post by Rachael »

Can that be done on specific files like r_all.cpp and poly_all.cpp rather than the entire project?
dpJudas
 
 
Posts: 3174
Joined: Sat May 28, 2016 1:01 pm

Re: Software renderer crashes on Linux

Post by dpJudas »

As far as I know, the broken code isn't part of those files. But I was more thinking of specifying something like -fno-tree-vectorize globally, or whatever other pass it is that causes it to crash.
User avatar
Rachael
Posts: 13964
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Software renderer crashes on Linux

Post by Rachael »

Ah. >_> My mistake.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49246
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Software renderer crashes on Linux

Post by Graf Zahl »

Rachael wrote:Can that be done on specific files like r_all.cpp and poly_all.cpp rather than the entire project?

Those two files contain all relevant SSE code, so it'd be a bad idea.
_mental_
 
 
Posts: 3820
Joined: Sun Aug 07, 2011 4:32 am

Re: Software renderer crashes on Linux

Post by _mental_ »

Well, SSE support isn't completely broken with GCC, it simply has some issues.
Most of Linux distros use GCC by default and disabling SSE would be an overkill.

Moreover I doubt that it's possible to disable SSE for x64 builds.
At least floats/double are passed to functions using XMM registers.

Actually, this can be the only problem we have with this instruction set in GCC.
Need to think what will do with it though.
dpJudas
 
 
Posts: 3174
Joined: Sat May 28, 2016 1:01 pm

Re: Software renderer crashes on Linux

Post by dpJudas »

If this one function is the only crash we have, then I can fix it by rewriting it. Its current version looks visually terrible anyway.
dpJudas
 
 
Posts: 3174
Joined: Sat May 28, 2016 1:01 pm

Re: Software renderer crashes on Linux

Post by dpJudas »

I commited a version of OpenGLSWFrameBuffer::OpenGLPal::Update that does some SSE using intrinsics to prevent GCC from optimizing it using the auto-vectorizer. Hopefully that should make it stop crashing at this location.
User avatar
Chris
Posts: 2979
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Re: Software renderer crashes on Linux

Post by Chris »

Another option may be to replace -O3 with -O2. I often hear "-O3 could do bad stuff in the past because of bugs, but it's fine now!" while also continuing to hear stories like this. It's also been said that -O3 may not produce more efficient code than -O2 anyway, due to over-optimizing and not accounting for things like code size effecting cache locality (and similar stories of -Os sometimes being faster than -O2/3).
User avatar
Rachael
Posts: 13964
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Software renderer crashes on Linux

Post by Rachael »

I'd like to do some speed tests with Clang before we make the official switch since Clang does not seem to have -O3 issues - I'd probably suggest only doing it for GCC.
Post Reply

Return to “Closed Bugs [GZDoom]”