BasFaggingerAuer / tiny-game-engine

A small OpenGL game engine.
GNU General Public License v3.0
13 stars 4 forks source link

Segmentation fault on glPrimitiveRestartIndexNV in initOpenGL() #20

Closed takenu closed 7 years ago

takenu commented 7 years ago

Since the SDL2 migration I can't run any of the tiny-game-engine's executables anymore (nor Strata, when trying to migrate that as well), as every one of them crashes at the same place: line 256 of /tiny/os/sdlapplication.cpp.

The gdb output is as follows:

takenu@takenui7:~/chathran/tiny-game-engine/build$ gdb test_Font 
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test_Font...done.
(gdb) run
Starting program: /home/takenu/chathran/tiny-game-engine/build/test_Font 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Initialising SDL...
[New Thread 0x7fffe8910700 (LWP 5360)]
[Thread 0x7fffe8910700 (LWP 5360) exited]
Creating a 1920x980 window at 0 bits per pixel...
Initialising OpenGL...
Using OpenGL version 3.2.0 NVIDIA 346.96.
Using GLSL version 1.50 NVIDIA via Cg compiler.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000000417e6c in tiny::os::SDLApplication::initOpenGL (this=<optimized out>) at /home/takenu/chathran/tiny-game-engine/tiny/os/sdlapplication.cpp:256
#2  0x0000000000418225 in tiny::os::SDLApplication::SDLApplication (this=0x683fd0, a_screenWidth=@0x7fffffffddd0: 1920, a_screenHeight=<optimized out>, fullScreen=@0x7fffffffddcf: false, a_screenBPP=<optimized out>, a_screenDepthBPP=<optimized out>) at /home/takenu/chathran/tiny-game-engine/tiny/os/sdlapplication.cpp:109
#3  0x000000000040c5eb in main () at /home/takenu/chathran/tiny-game-engine/src/test_Font.cpp:97
(gdb) 

I am no GL expert so I have no idea what you're using this for. Main questions would be: is this an OpenGL extension with poor support (note my OpenGL version should be high enough), and is this function strictly necessary as it is?

takenu commented 7 years ago

Supplementary info: if I comment out this line, it takes a little while longer until a crash occurs anyway, in e.g. /tiny/draw/texture.cpp:140 in a call to glGenerateMipmap. It could thus be that somehow OpenGL is deeply confused, but extensively looking at the changes of commit 07b4caad349a3bcc26c37c402f6316491570d141 did not show any obvious change to me that should cause this. It must be something with SDL2 working differently with OpenGL than SDL 1.2 did, but I'm clueless.

takenu commented 7 years ago

Actually test_Font runs fine when I remove the line

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

from /tiny/os/sdlapplication.cpp : 86.

Any clues on why setting the minor version to 2 (which seems fine, see log in initial post) would cause this behavior? I'm lost...

Edit: Actually, got it. Googling for "SDL_GL_CONTEXT_MINOR_VERSION" led me here where just a small adjustment is sufficient. Hold on... pull request coming.

BasFaggingerAuer commented 7 years ago

Hmmm, no idea. I have commented the line in the latest commit such that the code works, but I do not understand why this causes issues.

The functions on the lines that caused crashes for you before are all part of the OpenGL 3.2 core, so they should work fine. (Do you have the latest nvidia drivers?)

On Thu, Oct 20, 2016 at 8:41 PM, Matthijs notifications@github.com wrote:

Actually test_Font runs fine when I remove the line

SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

from /tiny/os/sdlapplication.cpp : 86.

Any clues on why setting the minor version to 2 (which seems fine, see log in initial post) would cause this behavior? I'm lost...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BasFaggingerAuer/tiny-game-engine/issues/20#issuecomment-255192257, or mute the thread https://github.com/notifications/unsubscribe-auth/ABY7PrXFLr5dKL2QOJe6HatMQwxECT2bks5q17XzgaJpZM4KbXwn .

BasFaggingerAuer commented 7 years ago

Can you try the latest commit? It all works fine for my Debian install with an GeForce 750 Ti + nvidia binary driver. You need OpenGL >= 3.2 to use this code, so that is unlikely to be a problem.

If this does not work, can you try commenting out line 82 of sdlapplication.cpp? (This line enforces having only core OpenGL functionality.)

On Wed, Oct 19, 2016 at 10:08 PM, Matthijs notifications@github.com wrote:

Supplementary info: if I comment out this line, it takes a little while longer until a crash occurs anyway, in e.g. /tiny/os/texture.cpp:140 in a call to glGenerateMipmap. It could thus be that somehow OpenGL is deeply confused, but extensively looking at the changes of commit 07b4caa https://github.com/BasFaggingerAuer/tiny-game-engine/commit/07b4caad349a3bcc26c37c402f6316491570d141 did not show any obvious change to me that should cause this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BasFaggingerAuer/tiny-game-engine/issues/20#issuecomment-254925624, or mute the thread https://github.com/notifications/unsubscribe-auth/ABY7Pt2hgOa8ZgdIGKMSHq69E4ILgFBQks5q1niugaJpZM4KbXwn .

takenu commented 7 years ago

That remark was about the latest commit.

It works now for me, but you committed material (in commits at https://github.com/BasFaggingerAuer/tiny-game-engine/commit/866619d5458556a4996fc016ad3780c70c7ce279 and https://github.com/BasFaggingerAuer/tiny-game-engine/commit/2173ba867e13af9918e3549b49052a8e1ac72912 ) that were not required to fix things on my end. Just the pull request (which you merged as well) fixed it.

As mentioned, my OpenGL version is 4.5 (unless forced down to 3.2 by enforcing the core profile). Proper functioning of tiny-game-engine seems to be guaranteed unless one does both of the following: (1) enforce major version 3, minor version 2 and (2) enforce core profile only.

I have no good explanation of why my OpenGL rejects functions that, according to OpenGL documentation I could find, is perfectly acceptable under OpenGL 3.2.

On 25 October 2016 at 20:56, Bas Fagginger Auer notifications@github.com wrote:

Can you try the latest commit? It all works fine for my Debian install with an GeForce 750 Ti + nvidia binary driver. You need OpenGL >= 3.2 to use this code, so that is unlikely to be a problem.

If this does not work, can you try commenting out line 82 of sdlapplication.cpp? (This line enforces having only core OpenGL functionality.)

On Wed, Oct 19, 2016 at 10:08 PM, Matthijs notifications@github.com wrote:

Supplementary info: if I comment out this line, it takes a little while longer until a crash occurs anyway, in e.g. /tiny/os/texture.cpp:140 in a call to glGenerateMipmap. It could thus be that somehow OpenGL is deeply confused, but extensively looking at the changes of commit 07b4caa https://github.com/BasFaggingerAuer/tiny-game-engine/commit/ 07b4caad349a3bcc26c37c402f6316491570d141 did not show any obvious change to me that should cause this.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BasFaggingerAuer/tiny-game- engine/issues/20#issuecomment-254925624, or mute the thread https://github.com/notifications/unsubscribe-auth/ ABY7Pt2hgOa8ZgdIGKMSHq69E4ILgFBQks5q1niugaJpZM4KbXwn

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BasFaggingerAuer/tiny-game-engine/issues/20#issuecomment-256140521, or mute the thread https://github.com/notifications/unsubscribe-auth/ALT4w_667xnnefkiN9jJNmbFfTO5vfDzks5q3lDogaJpZM4KbXwn .