summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-03-09 14:47:05 +0100
committerDamjan Marion <damarion@cisco.com>2022-03-09 14:47:05 +0100
commit317cace6185ae134d78a38e1a20249baf751035e (patch)
treebc7121e745cbb169a4cd8bfdcbb7e8546982274d /src
parent7fc0ee7f65fbbced6e987f8bfd927a595b7ff7ee (diff)
vat: fix vat_suspend crash
Deadly combination is clib_{set,long}jmp + lazy linking + tail call compiler optimization. On the first call to clib_setjmp, dynamic linker executes loader code which then calls clib_setjmp, so stored stack position contains dynamic loader data. Tail call optimization simply jumps back to the calling code when clib_longjump is called and that results in wrong return address used from the stack. Change-Id: Ia7d8dbd5b2c425cdd0449374aa07ab6b684a330e Type: fix Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vpp/api/api_main.c4
-rw-r--r--src/vppinfra/clib.h6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/vpp/api/api_main.c b/src/vpp/api/api_main.c
index 9b915eeffcf..63bb5f21c06 100644
--- a/src/vpp/api/api_main.c
+++ b/src/vpp/api/api_main.c
@@ -4,8 +4,8 @@
vat_main_t vat_main;
-void
-vat_suspend (vlib_main_t * vm, f64 interval)
+void __clib_no_tail_calls
+vat_suspend (vlib_main_t *vm, f64 interval)
{
vlib_process_suspend (vm, interval);
}
diff --git a/src/vppinfra/clib.h b/src/vppinfra/clib.h
index b3a2580e73a..76dd0ebf2ad 100644
--- a/src/vppinfra/clib.h
+++ b/src/vppinfra/clib.h
@@ -109,6 +109,12 @@
#define __clib_section(s) __attribute__ ((section(s)))
#define __clib_warn_unused_result __attribute__ ((warn_unused_result))
#define __clib_export __attribute__ ((visibility("default")))
+#ifdef __clang__
+#define __clib_no_tail_calls __attribute__ ((disable_tail_calls))
+#else
+#define __clib_no_tail_calls \
+ __attribute__ ((optimize ("no-optimize-sibling-calls")))
+#endif
#define never_inline __attribute__ ((__noinline__))