[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dpdk-users
Subject:    [dpdk-users] segmentation fault when calling rte_pktmbuf_alloc() after calling rte_pktmbuf_pool_crea
From:       Huai-En Tseng <the () csie ! io>
Date:       2020-06-12 7:41:58
Message-ID: F4B3B0EA-C19A-4A4E-8839-3FEC51266526 () csie ! io
[Download RAW message or body]

Hi all, there is a weird problem as title, 

When I use rte_pktmbuf_alloc(struct rte_mempool *) and already verify the return \
value of rte_pktmbuf_pool_create() is not NULL, the process receive segmentation \
fault.

Following message is out of gdb:

Thread 1 "osw" received signal SIGSEGV, Segmentation fault.
0x00000000005e9f41 in __mempool_generic_get (cache=0x1a7dfc000000000, n=1, \
obj_table=0x7fffffffdec8, mp=0x101a7df00)  at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1449 1449           \
if (unlikely(cache == NULL || n >= cache->size)) (gdb) p cache
$1 = (struct rte_mempool_cache *) 0x1a7dfc000000000
(gdb) bt
#0  0x00000000005e9f41 in __mempool_generic_get (cache=0x1a7dfc000000000, n=1, \
obj_table=0x7fffffffdeb8, mp=0x101a7df00)  at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1449 #1  \
rte_mempool_generic_get (cache=0x1a7dfc000000000, n=1, obj_table=0x7fffffffdeb8, \
mp=0x101a7df00)  at /root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1517
 #2  rte_mempool_get_bulk (n=1, obj_table=0x7fffffffdeb8, mp=0x101a7df00)
    at /root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1552
#3  rte_mempool_get (obj_p=0x7fffffffdeb8, mp=0x101a7df00) at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1578 #4  \
rte_mbuf_raw_alloc (mp=0x101a7df00) at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mbuf.h:586 #5  \
rte_pktmbuf_alloc (mp=0x101a7df00) at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mbuf.h:896

And I dig into rte_mempool.h:
and change line 1449-1450 
1449  if (unlikely(cache == NULL || n >= cache->size))
1450         goto ring_dequeue;
to 
1449  if (unlikely(cache == NULL))
1450          goto ring_dequeue;
1451  if (unlikely(n >= cache->size))
1452          goto ring_dequeue;

and it also fail at line 1451

the gdb output message after changing: 

Thread 1 "osw" received signal SIGSEGV, Segmentation fault.
__mempool_generic_get (cache=0x1a7dfc000000000, n=1, obj_table=0x7fffffffdeb8, \
mp=0x101a7df00)  at /root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1451
 1451            if (unlikely(n >= cache->size))
(gdb) p cache
$1 = (struct rte_mempool_cache *) 0x1a7dfc000000000
(gdb) bt
#0  __mempool_generic_get (cache=0x1a7dfc000000000, n=1, obj_table=0x7fffffffdeb8, \
mp=0x101a7df00)  at /root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1451
 #1  rte_mempool_generic_get (cache=0x1a7dfc000000000, n=1, obj_table=0x7fffffffdeb8, \
mp=0x101a7df00)  at /root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1519
 #2  rte_mempool_get_bulk (n=1, obj_table=0x7fffffffdeb8, mp=0x101a7df00)
    at /root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1554
#3  rte_mempool_get (obj_p=0x7fffffffdeb8, mp=0x101a7df00) at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mempool.h:1580 #4  \
rte_mbuf_raw_alloc (mp=0x101a7df00) at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mbuf.h:586 #5  \
rte_pktmbuf_alloc (mp=0x101a7df00) at \
/root/dpdk-20.05/x86_64-native-linuxapp-gcc/include/rte_mbuf.h:896 #6  main \
(argc=<optimized out>, argv=<optimized out>) at ofpd.c:150 (gdb) p cache->size
Cannot access memory at address 0x1a7dfc000000000

It looks like the memory address "cache" pointer stored is not NULL but it actually \
is a NULL pointer.

Does anyone know this issue?

The DPDK version is 20.05, I also tried 18.11 and 19.11.

OS is CentOS 8.1 kernel is 4.18.0-147.el8.x86_64.

I have reduce my code in program to just calling rte_eal_init() then \
rte_pktmbuf_pool_create() and rte_pktmbuf_alloc().

Thanks.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic