OSDN Git Service

[emulator] Delete VAOs starting from highest
authorLingfeng Yang <lfy@google.com>
Fri, 23 Dec 2016 02:00:35 +0000 (18:00 -0800)
committerLingfeng Yang <lfy@google.com>
Tue, 3 Jan 2017 17:44:32 +0000 (17:44 +0000)
commit5da143cb0811357c0b781ed4fca28fc85ee9207a
tree8595c431a9497770c91905b6ccb5070f4d0b3386
parent216980a5070cb675366c297af3ba64c19e2b2c69
[emulator] Delete VAOs starting from highest

If VAOs are deleted starting from 0, then the
following happens when an app's context has
genned two VAO's that are both != 0,
and the first of the two nonzero VAOs
is the current one:

VAO 0
VAO 1 <- current
VAO 2

in context dtor loop over vao map:
delete vao 0 (done)
delete vao 1:
is current, so bind 0:
in bind 0, we create a new map entry since 0 was deleted
next loop iter deletes vao 0 again (done)
*** at this point, vao 0 pointer refers to freed memory ***
next loop iter wants to delete vao 2,
but the current vao is 0 and refers to freed memory.
then, in Context::deleteVertexArray:
if (getCurrentVertexArray()->name...) <- Segmentation fault (core dumped)

This CL deletes VAO 0 last.

Change-Id: Ifa606ad7517cd213f21606577d3bdd8d810b640d
Reviewed-on: https://swiftshader-review.googlesource.com/8350
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
src/OpenGL/common/NameSpace.hpp
src/OpenGL/libGLESv2/Context.cpp