aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/linux/mem.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-02-02 15:40:35 -0800
committerDamjan Marion <dmarion@me.com>2021-02-04 15:10:01 +0000
commitb4d9c5dedb2209a021449d80ce3cbc9044072d84 (patch)
tree5fa1452f37bbfdc04de978b47c5952c70f740b7c /src/vppinfra/linux/mem.c
parent34c6c309d5ff7acfe470dac3f974271917e7b19e (diff)
vppinfra: fix mem map mt issue due to snprintf
Type: fix Apparently snprintf is not thread safe!? Thread 6 "vpp_wk_3" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffeed1a3700 (LWP 819375)] 0x00007ffff58fc2b4 in __GI__IO_default_xsputn (n=<optimized out>, data=<optimized out>, f=<optimized out>) at genops.c:394 394 genops.c: No such file or directory. (gdb) bt 0 0x00007ffff58fc2b4 in __GI__IO_default_xsputn (n=<optimized out>, data=<optimized out>, f=<optimized out>) at genops.c:394 1 __GI__IO_default_xsputn (f=0x7ffeec35e050, data=<optimized out>, n=9) at genops.c:370 2 0x00007ffff58e127c in __vfprintf_internal (s=s@entry=0x7ffeec35e050, format=format@entry=0x7ffff5f833ce "%s", ap=ap@entry=0x7ffeec35e1d0, mode_flags=mode_flags@entry=2) at ../libio/libioP.h:948 3 0x00007ffff58f611a in __vsnprintf_internal (string=0x7ffed57ed018 "", maxlen=<optimized out>, format=0x7ffff5f833ce "%s", args=args@entry=0x7ffeec35e1d0, mode_flags=2) at vsnprintf.c:114 4 0x00007ffff5997fd1 in ___snprintf_chk (s=<optimized out>, maxlen=<optimized out>, flag=<optimized out>, slen=<optimized out>, format=<optimized out>) at snprintf_chk.c:38 5 0x00007ffff5f7fd74 in clib_mem_vm_map_internal (base=<optimized out>, log2_page_sz=<optimized out>, size=<optimized out>, fd=<optimized out>, offset=<optimized out>, name=0x0) at /scratch/fcoras/vpp/src/vppinfra/linux/mem.c:502 Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I8ff7cfed422273dbdc55068772e11f5e550a9b60
Diffstat (limited to 'src/vppinfra/linux/mem.c')
-rw-r--r--src/vppinfra/linux/mem.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 121bf9473f0..15c5735d841 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -491,6 +491,7 @@ clib_mem_vm_map_internal (void *base, clib_mem_page_sz_t log2_page_sz,
CLIB_MEM_UNPOISON (hdr, sys_page_sz);
hdr->next = 0;
hdr->prev = mm->last_map;
+ snprintf (hdr->name, CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1, "%s", (char *) name);
mm->last_map = hdr;
map_unlock ();
@@ -499,7 +500,6 @@ clib_mem_vm_map_internal (void *base, clib_mem_page_sz_t log2_page_sz,
hdr->log2_page_sz = log2_page_sz;
hdr->num_pages = size >> log2_page_sz;
hdr->fd = fd;
- snprintf (hdr->name, CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1, "%s", (char *) name);
hdr->name[CLIB_VM_MAP_HDR_NAME_MAX_LEN - 1] = 0;
mprotect (hdr, sys_page_sz, PROT_NONE);