radeonsi: Fix crash when destroying si_screen
authorTom Stellard <thomas.stellard@amd.com>
Wed, 7 Jan 2015 18:49:12 +0000 (13:49 -0500)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 7 Jan 2015 21:28:40 +0000 (16:28 -0500)
We were invalidating si_screen:tm by calling
r600_destroy_common_screen() which frees the si_screen object.  This
caused the driver to crash in LLVMDisposeTargetMachine() since we
were passing it an invalid pointer.

https://bugs.freedesktop.org/show_bug.cgi?id=88170

src/gallium/drivers/radeonsi/si_pipe.c

index 38bff31e0056d8bf70d7bdbbdfd8de12ca729770..e3f8fcf80322763b1866b2ac8f3579cffa92e01c 100644 (file)
@@ -424,11 +424,13 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
        if (!sscreen->b.ws->unref(sscreen->b.ws))
                return;
 
-       r600_destroy_common_screen(&sscreen->b);
-
 #if HAVE_LLVM >= 0x0306
+       // r600_destroy_common_screen() frees sscreen, so we need to make
+       // sure to dispose the TargetMachine before we call it.
        LLVMDisposeTargetMachine(sscreen->tm);
 #endif
+
+       r600_destroy_common_screen(&sscreen->b);
 }
 
 #define SI_TILE_MODE_COLOR_2D_8BPP  14