mirror of https://github.com/citusdata/citus.git
Merge pull request #2647 from citusdata/fix_alloca_bug
Ensure that stack resizing logic works expectedpull/2650/head
commit
87db7a7578
|
@ -52,6 +52,7 @@
|
||||||
#include "distributed/worker_manager.h"
|
#include "distributed/worker_manager.h"
|
||||||
#include "distributed/worker_protocol.h"
|
#include "distributed/worker_protocol.h"
|
||||||
#include "distributed/worker_shard_visibility.h"
|
#include "distributed/worker_shard_visibility.h"
|
||||||
|
#include "port/atomics.h"
|
||||||
#include "postmaster/postmaster.h"
|
#include "postmaster/postmaster.h"
|
||||||
#include "optimizer/planner.h"
|
#include "optimizer/planner.h"
|
||||||
#include "optimizer/paths.h"
|
#include "optimizer/paths.h"
|
||||||
|
@ -261,7 +262,24 @@ ResizeStackToMaximumDepth(void)
|
||||||
long max_stack_depth_bytes = max_stack_depth * 1024L;
|
long max_stack_depth_bytes = max_stack_depth * 1024L;
|
||||||
|
|
||||||
stack_resizer = alloca(max_stack_depth_bytes);
|
stack_resizer = alloca(max_stack_depth_bytes);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Different architectures might have different directions while
|
||||||
|
* growing the stack. So, touch both ends.
|
||||||
|
*/
|
||||||
|
stack_resizer[0] = 0;
|
||||||
stack_resizer[max_stack_depth_bytes - 1] = 0;
|
stack_resizer[max_stack_depth_bytes - 1] = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Passing the address to external function also prevents the function
|
||||||
|
* from being optimized away, and the debug elog can also help with
|
||||||
|
* diagnosis if needed.
|
||||||
|
*/
|
||||||
|
elog(DEBUG5, "entry stack is at %p, increased to %p, the top and bottom values of "
|
||||||
|
"the stack is %d and %d", &stack_resizer[0],
|
||||||
|
&stack_resizer[max_stack_depth_bytes - 1],
|
||||||
|
stack_resizer[max_stack_depth_bytes - 1], stack_resizer[0]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue