[PATCH 2/3] fiber: Make sure the guard page is created

Cyrill Gorcunov gorcunov at gmail.com
Wed Oct 2 21:42:05 MSK 2019


The mprotect() syscall may fail due to heavy memory
pressure (say there is no enough resources to split
VMAs and etc).

In this case we must not proceed without guard page
but refuse to create a new fiber.

Closes #4541
---
 src/lib/core/fiber.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
index dde556b85..a7dc665ff 100644
--- a/src/lib/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -926,7 +926,11 @@ fiber_stack_create(struct fiber *fiber, size_t stack_size)
 						  (char *)fiber->stack +
 						  fiber->stack_size);
 
-	fiber_mprotect(guard, page_size, PROT_NONE);
+	if (fiber_mprotect(guard, page_size, PROT_NONE)) {
+		fiber_stack_destroy(fiber, &cord()->slabc);
+		return -1;
+	}
+
 	fiber_stack_watermark_create(fiber);
 	return 0;
 }
-- 
2.20.1




More information about the Tarantool-patches mailing list