- Notifications
You must be signed in to change notification settings - Fork5.2k
Commitce161b1
committed
aio: Stop using enum bitfields due to bad code generation
During an investigation into rather odd aio related errors on macos, observedby Alexander and Konstantin, we started to wonder if bitfield access isrelated to the error. At the moment it looks like it is related, we cannotreproduce the failures when replacing the bitfields. In addition, the problemcan only be reproduced with some compiler [versions] and not everyone has beenable to reproduce the issue.The observed problem is that, very rarely, PgAioHandle->{state,target} are inan inconsistent state, after having been checked to be in a valid state notlong before, triggering an assertion failure. Unfortunately, this could becaused by wrong compiler code generation or somehow of missing memory barriers- we don't really know. In theory there should not be any concurrent writeaccess to the handle in the state the bug is triggered, as the handle was idleand is just being initialized.Separately from the bug, we observed that at least gcc and clang generaterather terrible code for the bitfield access. Even if it's not clear if theobserved assertion failure is actually caused by the bitfield somehow, the badcode generation alone is sufficient reason to stop using bitfields.Therefore, replace the enum bitfields with uint8s and instead cast in eachswitch statement.Reported-by: Alexander Lakhin <exclusion@gmail.com>Reported-by: Konstantin Knizhnik <knizhnik@garret.ru>Discussion:https://postgr.es/m/1500090.1745443021@sss.pgh.pa.usBackpatch-through: 181 parentbaf45ba commitce161b1
File tree
5 files changed
+21
-15
lines changed- src
- backend/storage/aio
- include/storage
5 files changed
+21
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
| 278 | + | |
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
603 | | - | |
| 603 | + | |
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
| |||
825 | 825 | | |
826 | 826 | | |
827 | 827 | | |
828 | | - | |
| 828 | + | |
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
| |||
905 | 905 | | |
906 | 906 | | |
907 | 907 | | |
908 | | - | |
| 908 | + | |
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
| |||
930 | 930 | | |
931 | 931 | | |
932 | 932 | | |
933 | | - | |
| 933 | + | |
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
| 225 | + | |
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
| 663 | + | |
664 | 664 | | |
665 | 665 | | |
666 | 666 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | | - | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | | - | |
| 108 | + | |
103 | 109 | | |
104 | 110 | | |
105 | | - | |
| 111 | + | |
106 | 112 | | |
107 | 113 | | |
108 | 114 | | |
| |||
0 commit comments
Comments
(0)