anathema's picture

AccessViolationException when creating handle in GLControl

Project:The Open Toolkit library
Version:1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:open
Description

This is running on an ATI IGP 320M. I suspect the drivers to be the culprit - they're ancient and there's no indication that there is a newer version available - but just to confirm, this is the exception I see:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at OpenTK.Platform.Windows.Wgl.Imports.CreateContext(IntPtr hDc)
at OpenTK.Platform.Windows.WinGLContext..ctor(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext, Int32 major, Int32 minor, GraphicsContextFlags flags)
at OpenTK.Platform.Windows.WinFactory.CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, Boolean directRendering, Int32 major, Int32 minor, GraphicsContextFlags flags)
at OpenTK.Graphics.GraphicsContext..ctor(GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags)
at OpenTK.WinGLControl.CreateContext(Int32 major, Int32 minor, GraphicsContextFlags flags)
at OpenTK.GLControl.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.UserControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

OS is WindowsXP, openTK version is the trunk. As usual, the code works on every other machine it's been tried on :-)


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

Sanity check: does glview work?

Try compiling and running with a debug version of OpenTK.dll and OpenTK.pdb. This will print diagnostics to the VS output window and will also add line numbers to the stack trace (please post both!)

anathema's picture

#2

The exception is being thrown at WinGLContext.cs line 72:

ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext));

I'll try your suggestions shortly - the machine is rebooting and taking its time about it :-(

anathema's picture

#3

It's a threading issue. The exception is only thrown if I try and perform GL operations from a BackgroundWorker - anything run on the main thread is fine.

anathema's picture

#4

I spoke too soon :-(

Suddenly everything is working. I wonder if it's related to the order in which things are initialised?

the Fiddler's picture

#5

Nvidia drivers 260.99 have a known issue with threading. Maybe you are hitting that bug? #2129: Multithreading test crashes on Windows 7 x64 / Nvidia 260.99

anathema's picture

#6

This is on ATI. All Nvidia cards I've tried work fine :-)

Mike O's picture

#7

That card only supports openGL 1.3 I think this is your problem.
Edit: I should mention, I get the same exact error on my old Nvidia 440MX. It only supprts Opengl 1.5.3

anathema's picture

#8

Ah :-) Yes, I know it's an old card! I was hoping that I might be able to reproduce a different error on it that one of my beta-testers is seeing, but no joy.

So - are we looking at something in OpenTK, or something that I'm doing wrong? Long-term, this particular graphics-card will not actually be supported by my app as it doesn't support a number of functions I will be requiring in the near future, but it would still be nice to iron out the bugs :-)

anathema's picture

#9

Ah-ha! :-) Creating my GLControl *before* calling Application.Run() seems to have fixed the problem.

Mike O's picture

#10

Happy you got it worked out.. Im sure someone else will need this info :)