Opened 13 years ago
Closed 13 years ago
#3791 closed defect (fixed)
OpenGL output format seg fault
Reported by: | dmorissette | Owned by: | toby |
---|---|---|---|
Priority: | normal | Milestone: | 6.0 release |
Component: | MapServer C Library | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | sdlime, tbonfort |
Description
I get a seg fault with any mapfile in glGetIntegerv() which is called by the OglRenderer constructor.
This is happening on a Ubuntu 10.04 Netbook. I realize that we should not expect high performance from a netbook, I was simply using it for testing. Here is the list of installed opengl-related packages:
ii freeglut3 2.6.0-0ubuntu2 OpenGL Utility Toolkit ii freeglut3-dev 2.6.0-0ubuntu2 OpenGL Utility Toolkit development files ii libftgl2 2.1.3~rc5-3 library to render text in OpenGL using FreeT ii libgl1-mesa-dev 7.7.1-1ubuntu3 A free implementation of the OpenGL API -- G ii libgl1-mesa-dri 7.7.1-1ubuntu3 A free implementation of the OpenGL API -- D ii libgl1-mesa-glx 7.7.1-1ubuntu3 A free implementation of the OpenGL API -- G ii libglitz-glx1 0.5.6-1build1 Glitz OpenGL library GLX backend ii libglitz1 0.5.6-1build1 Glitz OpenGL image compositing library ii libglu1-mesa 7.7.1-1ubuntu3 The OpenGL utility library (GLU) ii libglu1-mesa-dev 7.7.1-1ubuntu3 The OpenGL utility library -- development fi ii libqt4-opengl 4:4.6.2-0ubuntu5.1 Qt 4 OpenGL module
The following minimal mapfile can be used to reproduce the problem with shp2img:
shp2img -m empty_opengl.map -o /tmp/test.png
--- empty_opengl.map ---
MAP SIZE 400 300 EXTENT 0 0 400 300 OUTPUTFORMAT NAME 'OGL_PNG24' DRIVER 'OGL/PNG' IMAGEMODE RGB END LAYER TYPE POINT END END
And here is the GDB backtrace:
#0 0x002a0276 in glGetIntegerv () from /usr/lib/mesa/libGL.so.1 #1 0x080a91cf in OglRenderer (this=0x8157bf8, width=400, height=300, color=0x8152828) at mapoglrenderer.cpp:35 #2 0x080a89d5 in msImageCreateOgl (width=400, height=300, format=0x8153b48, bg=0x8152828) at mapogl.cpp:138 #3 0x080852ae in msPrepareImage (map=0x8150e08, allow_nonsquare=1) at mapdraw.c:148 #4 0x08085962 in msDrawMap (map=0x8150e08, querymap=0) at mapdraw.c:283 #5 0x0805307d in main (argc=5, argv=0xbffff3d4) at shp2img.c:299
Change History (7)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Looks like a bug in the order of OpenGL context initialization. Need to be more careful in the case of older drivers and video cards that do not have all the required features.
Taking a look now.
comment:3 by , 13 years ago
I think it is fine to not support "older drivers and video cards that do not have the required features" since opengl rendering is useful only if you've got the right hardware, but at a minimum we should detect those cases and produce an error (to avoid the seg fault).
comment:4 by , 13 years ago
Toby committed r11749: "Making OpenGL context creation more robust on older video cards and drivers."
Unfortunately this revision still gives a seg fault on my test machine, at a different location:
#0 0x002c7256 in glGetError () from /usr/lib/mesa/libGL.so.1 #1 0x08100659 in OglContext::initWindow () at mapoglcontext.cpp:446 #2 0x080fff22 in OglContext (this=0x81ba918, width=400, height=300) at mapoglcontext.cpp:25 #3 0x080f86e7 in OglRenderer (this=0x81ba860, width=400, height=300, color=0x81b96c8) at mapoglrenderer.cpp:33 #4 0x080f7e61 in msImageCreateOgl (width=400, height=300, format=0x81ba9a0, bg=0x81b96c8) at mapogl.cpp:145 #5 0x080c37fa in msPrepareImage (map=0x81b7ca8, allow_nonsquare=1) at mapdraw.c:148 #6 0x080c3eae in msDrawMap (map=0x81b7ca8, querymap=0) at mapdraw.c:283 #7 0x0808af8d in main (argc=5, argv=0xbffff414) at shp2img.c:299
comment:5 by , 13 years ago
The issue is that glGetError(), like other gl functions, should not likely be called when there's not yet an active glx context which is the case at the point of the segfault. Googling about "glGetError segfaults" shows that it can actually happen, although it is a bit unfortunate that a geterror method crashes, even if the opengl specs that the behaviour is undefined outside of a glx context...
(Note my fix in r11481: /trunk/mapserver/mapoglcontext.cpp: opengl rendered: error out properly if XOpenDisplay() fails . Will not solve Daniel's crash however)
comment:6 by , 13 years ago
Thanks rouault.
I have made another commit which avoids calling glGetError until after the context has been initialised and made current.
comment:7 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Thanks to both of you. I confirm that toby's last changeset (r11493) solved my seg fault problem. I now get a nice error message instead ("... could not find any configs. Likely your video card or drivers are not supported.") Perfect!
Oh, you also asked about the display adapter. Here is what lspci reports: