gl4es icon indicating copy to clipboard operation
gl4es copied to clipboard

Using box86 + gl4es causes Shovelknight to seg fault when attempting to run

Open ITotalJustice opened this issue 4 years ago • 12 comments

Using the command LIBGL_ES=2 LIBGL_GL=21 LIBGL_DIBGL_FBOFORCETEX=1 LD_LIBRARY_PATH=~/monolibs BOX86_LD_LIBRARY_PATH=lib:./lib:fmod/lib/:/lib:x86:lib32:/usr/i686-linux-gnu/lib:/usr/lib/arm-linux-gnueabihf box86 ShovelKnight results in a seg fault and the game failing to boot. The game can boot fine when not using gl4es.

the bt full is:

Program received signal SIGSEGV, Segmentation fault.
0xb6fb9bec in memcpy () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
(gdb) bt full
#0  0xb6fb9bec in memcpy () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
No symbol table info available.
#1  0x3ff00000 in ?? ()
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Let me know if you need more information.

ITotalJustice avatar Jul 31 '19 08:07 ITotalJustice

Mmmm, that backtrace is useless unfortunatly. It will be difficult to track down the issue :(

Maybe run it with valgrind, if you can? It may gives a bit more detail on what is going wrong.

ptitSeb avatar Jul 31 '19 08:07 ptitSeb

In fact, I think it would be easier to use BOX86_LOG=DEBUG to have the function beeing called. That would probably be enough to understand in what function it crash.

ptitSeb avatar Jul 31 '19 10:07 ptitSeb

8776|0x883f75b: Calling strlen(0x88a102a("ycshaders/anim2d_glsl_vsh39")) => return 0x0000001B
8776|0x883f782: Calling strlen(0x88a1046("ycshaders/anim2d_glsl_psh1")) => return 0x0000001A
8776|0x883fa35: Calling glCreateProgram (B63C933E, 00000003, B6B639AC...) => return 0x00000001
8776|0x883fa4b: Calling glCreateShader (00008B31, 00000003, B6B639AC...) => return 0x00000002
8776|0x883fa74: Calling glShaderSource (00000002, 00000001, 089E6BCC...) =>Segmentation fault

ITotalJustice avatar Jul 31 '19 10:07 ITotalJustice

Ah, glShaderSource? Damn, that's a simple function. Strange. In the gl4es sources, can you un comment line 11 of src/gl/shader.c to have debug info on shader operations, and launch again (no Box86 log needed this time) ?

ptitSeb avatar Jul 31 '19 13:07 ptitSeb

So i uncommented the define debug, re-compiled however the output is the same. I checked the usage page, in case i was supposed to pass args when running but i couldn't see anything there either.

ITotalJustice avatar Jul 31 '19 22:07 ITotalJustice

That's strange, it should printf each glShader function used, with parameters. Maybe the game is redirecting output somewhere? For box86 trace, did you used BOX86_TRACE_FILE=XXX ?

ptitSeb avatar Aug 01 '19 05:08 ptitSeb

I didn't use BOX86_TRACE_FILE= though i did just try it and its the same output (only now in a file). For getting the trace i was just using > log.txt to save it to a file.

ITotalJustice avatar Aug 01 '19 10:08 ITotalJustice

Ok. Still strange, it should printf the glCreateShader(...) and glShaderSource(...) details.

ptitSeb avatar Aug 01 '19 13:08 ptitSeb

Yeah. It does work for many other games that i have been testing, it prints out all the information, just not with shovelknight hmm.

ITotalJustice avatar Aug 01 '19 14:08 ITotalJustice

I guess it redirect stdout to some log file then. Maybe I should rewrite the printf to fprintf(stderr, ...) then?

ptitSeb avatar Aug 01 '19 14:08 ptitSeb

Sorry i've been away past few days. Here's the log:

LIBGL: Error while compiling shader 462. Original source is:
#version 120
vec4 ps_r0;
vec4 ps_t0 = gl_TexCoord[0];
uniform sampler2D ps_s0;
#define ps_v0 gl_Color
#define ps_oC0 gl_FragColor

void main()
{
	ps_t0 = texture2D(ps_s0, ps_t0.xy);
	ps_r0 = ps_v0 * ps_t0;
	ps_oC0 = ps_r0;
}


=======
ShaderConv Source is:
#version 100
precision highp float;
precision highp int;
varying lowp vec4 _gl4es_FrontColor;
varying mediump vec4 _gl4es_TexCoord[1];
vec4 ps_r0;
vec4 ps_t0 = _gl4es_TexCoord[0];
uniform sampler2D ps_s0;
#define ps_v0 _gl4es_FrontColor
#define ps_oC0 gl_FragColor

void main()
{
	ps_t0 = texture2D(ps_s0, ps_t0.xy);
	ps_r0 = ps_v0 * ps_t0;
	ps_oC0 = ps_r0;
}


=======
Compiler message is
0:7(14): error: initializer of global variable `ps_t0' must be a constant expression

LIBGL: End of Error log
Failed to compile a pixel shader!
  '0:7(14): error: initializer of global variable `ps_t0' must be a constant expression
'
Wrote shader in question to badshader.bin
ERROR: Assert in /home/icculus/projects/psychonauts/Source/CommonLibs/DFGraphics/OpenGLGraphics.cpp, line 2127
pD3DShader != NULL

Encountered Error:
  Psychonauts has encountered an error

/home/icculus/projects/psychonauts/Source/CommonLibs/DFGraphics/OpenGLGraphics.cpp, line 2127
pD3DShader != NULL

 Please contact technical support at http://www.doublefine.com.

Unsupported Int 3 call
LIBGL: Shuting down

Did you want me to upload the full log output?

ITotalJustice avatar Aug 10 '19 22:08 ITotalJustice

No, it's ok, I can see the hack is not triggering here for some reason. I'll find why.

ptitSeb avatar Aug 11 '19 07:08 ptitSeb