Commit 6a3d396
committed
Fix core dump in ReorderBufferRestoreChange on alignment-picky platforms.
When re-reading an update involving both an old tuple and a new tuple from
disk, reorderbuffer.c was careless about whether the new tuple is suitably
aligned for direct access --- in general, it isn't. We'd missed seeing
this in the buildfarm because the contrib/test_decoding tests exercise this
code path only a few times, and by chance all of those cases have old
tuples with length a multiple of 4, which is usually enough to make the
access to the new tuple's t_len safe. For some still-not-entirely-clear
reason, however, Debian's sparc build gets a bus error, as reported by
Christoph Berg; perhaps it's assuming 8-byte alignment of the pointer?
The lack of previous field reports is probably because you need all of
these conditions to trigger a crash: an alignment-picky platform (not
Intel), a transaction large enough to spill to disk, an update within
that xact that changes a primary-key field and has an odd-length old tuple,
and of course logical decoding tracing the transaction.
Avoid the alignment assumption by using memcpy instead of fetching t_len
directly, and add a test case that exposes the crash on picky platforms.
Back-patch to 9.4 where the bug was introduced.
Discussion: <20160413094117.GC21485@msg.credativ.de>1 parent c2dc194 commit 6a3d396
File tree
3 files changed
+23
-4
lines changed- contrib/test_decoding
- expected
- sql
- src/backend/replication/logical
3 files changed
+23
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
| |||
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
| 249 | + | |
247 | 250 | | |
248 | | - | |
| 251 | + | |
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
253 | 256 | | |
| 257 | + | |
| 258 | + | |
254 | 259 | | |
255 | 260 | | |
256 | 261 | | |
| |||
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
263 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
264 | 271 | | |
265 | 272 | | |
266 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
| 134 | + | |
131 | 135 | | |
132 | 136 | | |
133 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2444 | 2444 | | |
2445 | 2445 | | |
2446 | 2446 | | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
2447 | 2451 | | |
2448 | 2452 | | |
2449 | 2453 | | |
| |||
2471 | 2475 | | |
2472 | 2476 | | |
2473 | 2477 | | |
2474 | | - | |
| 2478 | + | |
2475 | 2479 | | |
2476 | 2480 | | |
2477 | 2481 | | |
| |||
2492 | 2496 | | |
2493 | 2497 | | |
2494 | 2498 | | |
2495 | | - | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
2496 | 2504 | | |
2497 | 2505 | | |
2498 | 2506 | | |
| |||
0 commit comments