* * *

Author Topic: SDL2 minimal example raises SIGSEV on most recent Fedora  (Read 2053 times)

soerensen3

  • Full Member
  • ***
  • Posts: 152
SDL2 minimal example raises SIGSEV on most recent Fedora
« on: October 09, 2017, 06:18:14 pm »
I've been using the headers of Tim Blume for SDL2 for quite a while. Since some time I get a SIGSEV exception when the program closes. Everything else works as expected and I can use SDL2 and OpenGL without problems.
I don't know if the problem is with SDL2 or the headers or even somewhere else, so I start by posting here.
I could reduce the code to this minimal example. If I init the video subsystem the error is raised after the "end.".
The error shows only on Linux but not on Windows (I tested only the most recent Korora Distribution which is based on Fedora). Please refer to the signature for details.
Code: Pascal  [Select]
  1. program sdl2_test;
  2.  
  3. uses sdl2;
  4.  
  5. begin
  6.   SDL_Init( SDL_INIT_VIDEO ); // If this is omitted no exception is raised
  7.   SDL_Quit; // Does not influence the exception
  8. end. // The Exception is raised after program execution
  9.  

The call stack looks like this
Quote
#0 _dl_catch_error at :0
#1 _dlerror_run at :0
#2 dlclose at :0
#3 CleanupVendorNameEntry(0x68e5e0, 0x68e5e0) at libglxmapping.c:321
#4 __glXMappingTeardown(0, 0) at libglxmapping.c:1061
#5 __glXFini at libglx.c:2099
#6 _dl_fini at :0
#7 __run_exit_handlers at :0
#8 exit at :0
#9 __libc_start_main at :0
#10 ?? at :0

I somehow suspect libglvnd has something to do with this because the c files belong to this package.
As far as I understood it was only recently made mandatory in Fedora (I can't find where I read that) and serves an abstraction layer between multiple implementations of OpenGL (e.g. NVidia and Intel) if you have more than one display adapter. I have an NVIDIA discrete adapter but only use the internal Intel adapter. Before I tried the rpm-fusion nvidia driver but it does not make any difference to the exception.

I tried to recreate the same code in C (compiled with GCC, debugging with GDB). And I couldn't find any issues there so it also might have something to do with fpc. However I have no experience with debugging in C. Here is the source.

Code: C  [Select]
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <SDL2/SDL.h>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     SDL_Init( SDL_INIT_VIDEO );
  8.     SDL_Quit();
  9. }
  10.  

Quote
gcc -Wall tmp.c -o tmp -lSDL2

Can anyone reproduce the error or have any suggestions on how to find the source of the error?
I'll attach the pascal source code including the used headers.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

de_jean_7777

  • New member
  • *
  • Posts: 11
Re: SDL2 minimal example raises SIGSEV on most recent Fedora
« Reply #1 on: November 16, 2017, 11:22:14 pm »
i have the same issue in my "engine", which uses X directly. I've not been able to figure out why it happens, but doesn't seem to happen with other non-fpc programs. This happens both under Wayland and X.
Existence is pain

soerensen3

  • Full Member
  • ***
  • Posts: 152
Re: SDL2 minimal example raises SIGSEV on most recent Fedora
« Reply #2 on: November 17, 2017, 12:21:08 am »
Do you use Fedora? I wasn't able to solve the problem. Or I kind of solved it by switching to Manjaro which runs a lot better with my hardware configuration. However I have another laptop with Fedora which I didn't update to the newest distro and there I don't have any issues. I wonder if it's something in the header files? But then why does it work in other distros?
What do you mean with using X directly? Do you create any windows that are not SDL windows?
Do you have an NVIDIA gpu?
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

de_jean_7777

  • New member
  • *
  • Posts: 11
Re: SDL2 minimal example raises SIGSEV on most recent Fedora
« Reply #3 on: November 23, 2017, 11:08:56 pm »
I use Fedora 27 x64, and I call the X11 api directly, no SDL. The laptop I use has a a GTX 950m and Intel HD Graphics 530. OpenGL renderer shows that the intel graphics is used.
Existence is pain

Cyrax

  • Hero Member
  • *****
  • Posts: 612
Re: SDL2 minimal example raises SIGSEV on most recent Fedora
« Reply #4 on: November 23, 2017, 11:28:28 pm »
Does adding {$CODEALIGN LOCALMIN=16} somewhere after program clause help?

soerensen3

  • Full Member
  • ***
  • Posts: 152
Re: SDL2 minimal example raises SIGSEV on most recent Fedora
« Reply #5 on: November 24, 2017, 02:12:36 am »
@de_jean_7777: But it uses libglvnd then. I think libglvnd is some wrapper for OpenGL calls which calls the OpenGL api for the GPU used. I also had the issue on my laptop with two GPU's only. I think on the other with Intel GPU only it also loaded libglvnd but it still worked. I will have a look at it again, as soon as I have time.

@Cyrax: Unfornuately I cannot test this. anymore as I don't have Fedora installed on this machine anymore but I would still be interested in the result. However it is strange that this behaviour does not occur in manjaro where there is also libglvnd installed.
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

de_jean_7777

  • New member
  • *
  • Posts: 11
Re: SDL2 minimal example raises SIGSEV on most recent Fedora
« Reply #6 on: November 25, 2017, 07:49:22 pm »
@Cyrax It does nothing :/ At least with fpc 3.0.4 rc1.
Existence is pain

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus