Commit c960054
authored
Guard against bad memory access in RenderPassSystem (#1153)
Fixes a bad memory access that in RenderPassSystem that happens in some linux builds.
On Ubuntu with gcc, global_##classname##Factory is initialized after RenderPassSystem::renderPassMap, so the Register call in the constructor for ##classname##Factory works as expected.
However, on some linux builds, global_##classname##Factory may be initialized before RenderPassSystem::renderPassMap, leading to a bad memory access.
This is fixed by using the Construct On First Use idiom, where the static renderPassMap member variable is replaced by a GetRenderPassMap() member function in which the actual static render pass map is instantiated. This member function is then called in RenderPassSystem::Register() and in RenderPassSystem::CreateImpl() to write to/ read from the static render map.
Signed-off-by: Shameek Ganguly <[email protected]>1 parent 3e695f9 commit c960054
File tree
2 files changed
+13
-6
lines changed- include/gz/rendering
- src
2 files changed
+13
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
49 | 47 | | |
50 | 48 | | |
51 | 49 | | |
| |||
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
0 commit comments