LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: glShaderSource() causes crash  (Read 70 times)

noblex

  • Newbie
  • *
  • Offline Offline
  • Posts: 1
glShaderSource() causes crash
« on: July 19, 2017, 14:11:22 »

Hello, this portion of code cause my program to throw an EXCEPTION_ACCESS_VIOLATION.

Quote
public Shader(String filename){
        Log.d(TAG, "Init " + filename);
        String filePath = GlobalVariables.SHA_PATH + filename;
        String vsPath = filePath + ".vs";
        String fsPath = filePath + ".fs";

        if( !(new File(vsPath).exists() )){
            Log.wtf(TAG, "Wrong filename: " + filename);
        }
        if( !(new File(fsPath).exists() )){
            Log.wtf(TAG, "Wrong filename: " + filename);
        }

        program = glCreateProgram();

        vertexShader = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(vertexShader, readFile(vsPath));
        glCompileShader(vertexShader);
        if(glGetShaderi(vertexShader, GL_COMPILE_STATUS) != 1){
            Log.wtf(TAG, "Cannot compile vertex shader " + filename + " " + glGetShaderInfoLog(vertexShader));
        }

        fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(fragmentShader, readFile(fsPath));
        glCompileShader(fragmentShader);
        if(glGetShaderi(fragmentShader, GL_COMPILE_STATUS) != 1){
            Log.wtf(TAG, "Cannot compile fragment shader " + filename + " " + glGetShaderInfoLog(fragmentShader));
        }

        glAttachShader(program, vertexShader);
        glAttachShader(program, fragmentShader);

        glBindAttribLocation(program, 0, "vertices");
        //glBindAttribLocation(program, 1, "textures");

        glLinkProgram(program);
        if(glGetProgrami(program, GL_LINK_STATUS)!=1){
            Log.wtf(TAG, "Cannot link program " + filename + " " + glGetProgramInfoLog(program));
        }

        glValidateProgram(program);
        glLinkProgram(program);
        if(glGetProgrami(program, GL_VALIDATE_STATUS)!=1){
            Log.wtf(TAG, "Cannot validate program " + filename + " " + glGetProgramInfoLog(program));
        }

    }


The crash is on instrunction glShaderSource().

This is the crash dump:

Quote
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ff9891624cd, pid=5032, tid=0x0000000000001fa0
#
# JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [lwjgl.dll+0x124cd]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Alex\Development\IdeaProjects\LWJGL_PROJECT\hs_err_pid5032.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
[LWJGL] A function that is not available in the current context was called. The JVM will abort execution. Inspect the crash log to find the responsible Java frames.
Disconnected from the target VM, address: '127.0.0.1:59659', transport: 'socket'


What could it be? Any solution?

Thanks
Logged

spasi

  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1837
Re: glShaderSource() causes crash
« Reply #1 on: July 19, 2017, 15:46:16 »

You're either calling a deprecated function in a core profile OpenGL context, or a function from an OpenGL version or extension that is not supported by your driver. I doubt it's glShaderSource (glCreateProgram & glCreateShader would fail as well). Open the hs_err_pid5032.log file and see if you can find that last native method called.

It's also possible that you're calling OpenGL functions in a thread with no OpenGL context current.
Logged