View Full Version : glReadPixels() occasional Nvidia driver crash
02-06-2008, 05:16 AM
I use glReadPixels() to get the current frame contents for the manual save-game and auto-save game slots. On some rare users computers (Nvidia gfx. card based), driver crashes somewhere between once per day (with approx. 8h of playing) and once per week.
I read the image from a pbuffer and whole OpenGL API usage is single-threaded.
The one way to blindedly try to workaround it is to read the image from the back-buffer...
Anyone else stumbled upon this bug / managed to workaround it?
02-06-2008, 07:19 AM
glReadPixels works like charm... It will be more usefull to post readback code. Maybe you miss something...
02-06-2008, 09:37 AM
used to happen to me sometimes when frequently reading to a recently allocated buffer. something like:
char *buffer = new char [numOfPixels];
would run into an access violation and crash my application.
But I never got around to figure out why.
Using a pre-allocated buffer like, for example:
extern char buffer[numofpixels];
solved the problem...Don't know if it helps though.
02-07-2008, 12:21 AM
I think, your memory allocation failed then in the first place returning a NULL pointer? Check the value of the "buffer"-pointer.
Do you free the memory later on? One technique I use to ensure proper memory cleanup is using std::vector<char> for such cases:
"buffer" will be cleaned up automatically (even in case of exceptions)...
02-07-2008, 07:36 AM
No, just checked it, I think it is something else for me(I always check for null pointers, use std::auto_ptr etc..).
I read a buffer after resizing the window at WM_SIZE time, so it is possible windows had not resized the application framebuffer, causing an access violation when the window size increased. Or something like that...
02-07-2008, 11:21 AM
There's definitely a driver bug on ReadPixels----because sometimes when I fail to allocate a sufficient amount of memory, calling ReadPixels will bluescreen my computer. I don't see any way that could happen except a driver bug.
However, it's always worked fine when the allocated memory is big enough.
02-08-2008, 02:40 AM
Couldn't it be related to the pack/unpack alignment ? Check glPixelStorei. If the buffer expected when performing glReadPixels is corrupting a bit of memory after what you allocated, it could explain the random crashes..
02-08-2008, 02:51 AM
Good point; the default values for alignment of pixel pack/unpack should be 1 instead of 4 (or 8?) as it is now!
02-08-2008, 07:05 AM
Bluescreen can not be related to packing. BSOD is driver or Windows bug. Plain and simple.
My bet is that the driver isn't checking the user provided buffer (ProbeForWrite). If it's due to a misdirected "shortcut" to gain a microsecond of performance or an oversight (a very large one at that) is of little concern if the end result is that the write to RAM overwrites the user provided buffer and overflows into physical RAM memory pages owned by the kernel (from kernel-mode the actual RAM after the memory the user process provided can be just about anything).
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.