forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita8b7424
committed
Be more rigorous about local variables in PostgresMain().
Since PostgresMain calls sigsetjmp, any local variables that are notmarked "volatile" have a risk of unspecified behavior. In practicethis means that when control returns via longjmp, such variables mightget reset to their values as of the time of sigsetjmp, depending onwhether the compiler chose to put them in registers or on the stack.We were careful about this for "send_ready_for_query", but not theother local variables.In the case of the timeout_enabled flags, resetting them totheir initial "false" states is actually good, since we do"disable_all_timeouts()" in the longjmp cleanup code path. If thatdoes not happen, we risk uselessly calling "disable_timeout()" later,which is harmless but a little bit expensive. Let's explicitly resetthese flags so that the behavior is correct and platform-independent.(This change means that we really don't need the new "volatile"markings after all, but let's install them anyway since any changein this logic could re-introduce a problem.)There is no issue for "firstchar" and "input_message" because thoseare explicitly reinitialized each time through the query processingloop. To make that clearer, move them to be declared inside the loop.That leaves us with all the function-lifespan locals except thesigjmp_buf itself marked as volatile, which seems like a good policyto have going forward.Because of the possibility of extra disable_timeout() calls, thisseems worth back-patching.Sergey Shinderuk and Tom LaneDiscussion:https://postgr.es/m/2eda015b-7dff-47fd-d5e2-f1a9899b90a6@postgrespro.ru1 parenta44d96a commita8b7424
1 file changed
+11
-6
lines changedLines changed: 11 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4111 | 4111 |
| |
4112 | 4112 |
| |
4113 | 4113 |
| |
4114 |
| - | |
4115 |
| - | |
4116 | 4114 |
| |
| 4115 | + | |
| 4116 | + | |
4117 | 4117 |
| |
4118 |
| - | |
4119 |
| - | |
| 4118 | + | |
| 4119 | + | |
4120 | 4120 |
| |
4121 | 4121 |
| |
4122 | 4122 |
| |
| |||
4322 | 4322 |
| |
4323 | 4323 |
| |
4324 | 4324 |
| |
4325 |
| - | |
4326 |
| - | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
4327 | 4329 |
| |
4328 | 4330 |
| |
4329 | 4331 |
| |
| |||
4418 | 4420 |
| |
4419 | 4421 |
| |
4420 | 4422 |
| |
| 4423 | + | |
| 4424 | + | |
| 4425 | + | |
4421 | 4426 |
| |
4422 | 4427 |
| |
4423 | 4428 |
| |
|
0 commit comments
Comments
(0)