aldacron
Joined: 05 May 2004 Posts: 1322 Location: Seoul, South Korea
|
Posted: Sun Feb 05, 2012 6:57 am Post subject: Access Violation on Windows |
|
|
OK, this has gone past annoyance for me now. From some time ago, I began to notice Access Violations when exiting a program using DerelictAllegro. IIRC, it popped up with DerelictSDL, too. It appears to be a memory stomping bug, as adding and removing lines changes the addresses that show up in the output and often causes it to, eventually, disappear.
I've now encountered the same problem with the new Derelict3 branch using DerelictGLFW3 + DerelictGL3. The error happens *after* the main method returns, which means it's happening in DRuntime. It appears to be happening before any module dtors are actually run, but I can't be sure. I get no useful stack trace (just a bunch of memory addresses), despite having built and linked with debug versions of Phobos and Druntime. Finally, WinDbg has proven to be a dead end.
My next step is to see how far I can get debugging with Visual Studio, but my expectations are low. In the mean time, I'm posting here in the hopes that someone out there can help me make some progress on this. I really want to figure out what is causing this and put it to an end once and for all.
Compile the following example and link with the DerelictGLFW3, DerelictGL3 and DerelictUtil from the Derelict3 repo.line).
Code: |
module gl.window;
import core.thread;
import std.conv : to;
import derelict.util.loader;
import derelict.opengl3.gl3;
import derelict.glfw3.glfw3;
enum title = "GLFW Window";
void main()
{
init();
scope(exit) term();
run();
}
GLFWwindow _window;
void init()
{
SharedLibLoader.disableAutoUnload();
DerelictGL3.load();
DerelictGLFW3.load();
if(!glfwInit())
throw new Exception("glfwInit failure: " ~ to!string(glfwErrorString(glfwGetError())));
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
_window = glfwOpenWindow(1024, 768, GLFW_WINDOWED, title, null);
if(!_window)
throw new Exception("Failed to create window: " ~ to!string(glfwErrorString(glfwGetError())));
DerelictGL3.reload();
glfwEnable(_window, GLFW_STICKY_KEYS);
glfwSwapInterval(1);
}
void term()
{
if(DerelictGLFW3.isLoaded)
glfwTerminate();
DerelictGLFW3.unload();
DerelictGL3.unload();
}
void run()
{
do
{
glfwSwapBuffers();
glfwPollEvents();
Thread.yield();
}
while(glfwIsWindow(_window) &&
glfwGetKey(_window, GLFW_KEY_ESCAPE) != GLFW_PRESS);
}
|
Or, alternatively, download this 7-zip file which contains everything, including a precompiled glfw.dll. You'll first need to cd to the build folder and execute derelict.exe to build the Derelict libs, then you can cd to the source dir and execute the following command line:
dmd -I..\import gl\window.d
Add whatever flags you need to play around with. I'd love to know if it's reproducible. I'd particularly like to know if this problem shows up on other platforms. _________________ The One With D | The One With Aldacron | D Bits |
|