[vm/simulators] Check for C++ stack overflow when entering runtime in simulators
On simulated architectures (simarm, simarm64) machine code checks stack overflow of the simulated (arm/arm64) stack. However, it is also possible to overflow C++ stack used by simulator and runtime if runtime code is called recursively. This change adds C++ stack overflow check on entry into the runtime code (on simulated architectures). Fixes https://github.com/dart-lang/sdk/issues/42936 Change-Id: If8f9388a1edc06044402f052c1d10d79063477e9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157103 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
8661e01552
commit
08b7552b60
@@ -85,6 +85,15 @@ class RuntimeEntry : public BaseRuntimeEntry {
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if defined(USING_SIMULATOR)
|
||||
#define CHECK_SIMULATOR_STACK_OVERFLOW() \
|
||||
if (!OSThread::Current()->HasStackHeadroom()) { \
|
||||
Exceptions::ThrowStackOverflow(); \
|
||||
}
|
||||
#else
|
||||
#define CHECK_SIMULATOR_STACK_OVERFLOW()
|
||||
#endif // defined(USING_SIMULATOR)
|
||||
|
||||
// Helper macros for declaring and defining runtime entries.
|
||||
|
||||
#define DEFINE_RUNTIME_ENTRY(name, argument_count) \
|
||||
@@ -106,6 +115,7 @@ class RuntimeEntry : public BaseRuntimeEntry {
|
||||
TransitionGeneratedToVM transition(thread); \
|
||||
StackZone zone(thread); \
|
||||
HANDLESCOPE(thread); \
|
||||
CHECK_SIMULATOR_STACK_OVERFLOW(); \
|
||||
DRT_Helper##name(isolate, thread, zone.GetZone(), arguments); \
|
||||
} \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user