Strange segfault (Derelict/OpenGL)

John Colvin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Aug 29 04:54:16 PDT 2014


On Friday, 29 August 2014 at 11:23:34 UTC, Robin Schroer wrote:
> I'm not entirely sure where to post, so I will put it here.
>
> I'm playing around with D and Derelict 3 to make something with 
> OpenGL (don't really know what yet). I managed to open a 
> window, add an OpenGL context, clear the screen and flip 
> buffers. But as soon as I try to render a triangle, my program 
> crashes. I already tried hardcoding values in the shaders to 
> rule them out. I end up with:
>
> Error executing command run: Program exited with code -11
>
> Upon running with gdb, I get:
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000000000 in ?? ()
>
> which is not really helpful to me.
>
> dub -v's output:
>
> [...]
>
> Full exception: 
> object.Exception at source/dub/generators/build.d(405): Program 
> exited with code -11
> ----------------
> dub(pure @safe bool std.exception.enforce!(bool).enforce(bool, 
> lazy const(char)[], immutable(char)[], ulong)+0x6b) [0x67346f]
> dub(void 
> dub.generators.build.BuildGenerator.runTarget(dub.internal.vibecompat.inet.path.Path, 
> const(dub.compilers.compiler.BuildSettings), 
> immutable(char)[][])+0x4dc) [0x62db70]
> dub(void 
> dub.generators.build.BuildGenerator.generateTargets(dub.generators.generator.GeneratorSettings, 
> const(dub.generators.generator.ProjectGenerator.TargetInfo[immutable(char)[]]))+0x231) 
> [0x62a75d]
> dub(void 
> dub.generators.generator.ProjectGenerator.generate(dub.generators.generator.GeneratorSettings)+0x2de) 
> [0x62f9a2]
> dub(void dub.dub.Dub.generateProject(immutable(char)[], 
> dub.generators.generator.GeneratorSettings)+0xaa) [0x5f1f46]
> dub(int dub.commandline.GenerateCommand.execute(dub.dub.Dub, 
> immutable(char)[][], immutable(char)[][])+0x677) [0x5e5b6b]
> dub(int dub.commandline.BuildCommand.execute(dub.dub.Dub, 
> immutable(char)[][], immutable(char)[][])+0x8d) [0x5e5e81]
> dub(int dub.commandline.RunCommand.execute(dub.dub.Dub, 
> immutable(char)[][], immutable(char)[][])+0x8d) [0x5e6041]
> dub(int 
> dub.commandline.runDubCommandLine(immutable(char)[][])+0x1211) 
> [0x5e3b8d]
> dub(_Dmain+0x20) [0x5e2334]
> dub(void rt.dmain2._d_run_main(int, char**, extern (C) int 
> function(char[][])*).runAll().void __lambda1()+0x18) [0x6ce504]
> dub(void rt.dmain2._d_run_main(int, char**, extern (C) int 
> function(char[][])*).tryExec(scope void delegate())+0x2a) 
> [0x6ce45e]
> dub(void rt.dmain2._d_run_main(int, char**, extern (C) int 
> function(char[][])*).runAll()+0x30) [0x6ce4c4]
> dub(void rt.dmain2._d_run_main(int, char**, extern (C) int 
> function(char[][])*).tryExec(scope void delegate())+0x2a) 
> [0x6ce45e]
> dub(_d_run_main+0x1a3) [0x6ce3df]
> dub(main+0x25) [0x5e2979]
> /lib64/libc.so.6(__libc_start_main+0xf5) [0x3dcae21d65]
>
> I am using the current master versions of Derelict, dub 0.9.21, 
> dmd v2.066.0, on Linux 3.15.7 x86_64
>
> I can post my source if needed, but it is quite a lot already. 
> I'm not really sure if it is my fault or a bug in Derelict or 
> dmd, hopefully someone is able to track this down.
>
> --
>
> Robin Schroer

Are you following this pattern?:

// For core API functions.
import derelict.opengl3.gl3;

void main() {
     // Load OpenGL versions 1.0 and 1.1.
     DerelictGL3.load();

     // Create an OpenGL context with another library (like SDL 2 
or GLFW 3)
     ...

     // Load versions 1.2+ and all supported ARB and EXT 
extensions.
     DerelictGL3.reload();

     // Now OpenGL functions can be called.
     ...
}



The "Segfault in ??" error is usually from calling a function 
pointer that hasn't been initialised, e.g. a more recent OpenGL 
api function that is only bound by calling DerelictGL3.reload();


More information about the Digitalmars-d-learn mailing list