It's needed for Asan not to whine.
/* Process creation/destruction callbacks */
typedef void (*void_pfn_smxprocess_t) (smx_actor_t);
-extern int smx_context_stack_size;
+extern unsigned smx_context_stack_size;
extern int smx_context_stack_size_was_set;
-extern int smx_context_guard_size;
+extern unsigned smx_context_guard_size;
extern int smx_context_guard_size_was_set;
SG_BEGIN_DECL()
/* We are using the bottom of the stack to save some information, like the
* valgrind_stack_id. Define smx_context_usable_stack_size to give the remaining
- * size for the stack. */
+ * size for the stack. Round its value to a multiple of 16 (for stack alignment). */
#if HAVE_VALGRIND_H
-# define smx_context_usable_stack_size \
- (smx_context_stack_size - sizeof(unsigned int)) /* for valgrind_stack_id */
+#define smx_context_usable_stack_size \
+ ((smx_context_stack_size - sizeof(unsigned int)) & ~0xf) /* for valgrind_stack_id */
#else
-# define smx_context_usable_stack_size smx_context_stack_size
+#define smx_context_usable_stack_size (smx_context_stack_size & ~0xf)
#endif
/** @brief Executes all the processes to run (in parallel if possible). */
// We need to pass the bottom of the stack to make_fcontext, depending on the stack direction it may be the lower
// or higher address:
#if PTH_STACKGROWTH == -1
- void* stack = static_cast<char*>(this->stack_) + smx_context_usable_stack_size - 1;
+ void* stack = static_cast<char*>(this->stack_) + smx_context_usable_stack_size;
#else
void* stack = this->stack_;
#endif
(std::string("Possible values: ")+contexts_list()).c_str(),
context_factories[0].first);
-int smx_context_stack_size;
+unsigned smx_context_stack_size;
int smx_context_stack_size_was_set = 0;
-int smx_context_guard_size;
+unsigned smx_context_guard_size;
int smx_context_guard_size_was_set = 0;
#if HAVE_THREAD_LOCAL_STORAGE
static XBT_THREAD_LOCAL smx_context_t smx_current_context_parallel;
fprintf(stderr, "Access violation detected.\n"
"This probably comes from a programming error in your code, or from a stack\n"
"overflow. If you are certain of your code, try increasing the stack size\n"
- " --cfg=contexts/stack-size=XXX (current size is %d KiB).\n"
+ " --cfg=contexts/stack-size=XXX (current size is %u KiB).\n"
"\n"
"If it does not help, this may have one of the following causes:\n"
"a bug in SimGrid, a bug in the OS or a bug in a third-party libraries.\n"