Bug 29644

Summary: glsl2 regression: oolite and vegastrike segfault on initialization
Product: Mesa Reporter: Nicolas Kaiser <nikai>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: git   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: oolite backtrace

Description Nicolas Kaiser 2010-08-18 04:04:45 UTC
Created attachment 37947 [details]
oolite backtrace

KMS r600 classic:
With mesa git, oolite-1.74.2 segfaults on initialization.
Similarly, vegastrike-SVN segfaults on initialization with a comparable backtrace.

System environment:
-- system architecture: amd64
-- Linux distribution: Gentoo
-- GPU: RS780G
-- Model: ATI Radeon HD 3200
-- Display connector: VGA
-- xf86-video-ati: cc0a167ff2db9b097891883ded147af1d67e4407
-- xserver: 1.8.2
-- mesa: c17d5de593fbfee91b799894b1c1a8a37a6a9c95
-- drm: 431f7f00db844534dbcf9a63da0d2832a3d91bff
-- kernel: 2.6.35.1

This quick hack appears to fix the problem in both oolite and vegastrike:

--- src/mesa/program/ir_to_mesa.cpp	2010-08-18 12:57:53.822075251 +0200
+++ ir_to_mesa.cpp	2010-08-18 12:55:16.362920273 +0200
@@ -1145,7 +1145,7 @@
       if (!field && statevars[i].field) {
 	 assert(!"FINISHME: whole-structure state var dereference");
       }
-      if (field && strcmp(statevars[i].field, field) != 0)
+      if (field && statevars[i].field && strcmp(statevars[i].field, field) != 0)
 	 continue;
       break;
    }
Comment 1 Luca Barbieri 2010-08-18 04:18:18 UTC
I just sent a patch to Ian Romanick that should fix exactly this.

I think your patch is incorrect, though.

IMHO that line should be:
if (field && (!statevars[i].field || strcmp(statevars[i].field, field) != 0))
continue;

i.e. if the user specifies a field, but the entry we're examining doesn't have one, or it doesn't match, then it's not the one we are looking for.
Comment 2 Nicolas Kaiser 2010-08-18 04:40:04 UTC
Great, thanks! I just blindly tried to avoid the segfaults.

I tested your patch set, and it fixes the problems at my place.
Comment 3 Nicolas Kaiser 2010-08-20 14:13:59 UTC
Fixed with mesa: c3e3793c325e36366165a5d1403a8c406ff200db
 (glsl: add missing ambient field to gl_LightModel)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.