* [dpdk-users] 【dpdk eal parameter parse issue check】
@ 2019-01-17 12:38 Shen, Chuanpeng (NSB - CN/Hangzhou)
0 siblings, 0 replies; only message in thread
From: Shen, Chuanpeng (NSB - CN/Hangzhou) @ 2019-01-17 12:38 UTC (permalink / raw)
To: users
Hi,
DPDK experts, I need your help since I meet a problem when using DPDK interface rte_eal_init in eal.c
We added some more debug logs with some modification and we can see that when we are sending a dynamically allocated char* array to dpdk api(rte_eal_init) directly it's changing/corrupting some pointers which is creating issue later while freeing the memory.
● char* array ---> rte_eal_init ---> changing/corrupting some pointers
# /opt/nokia/tools/SS_RCPDPM/tools/dpm_diag_cli memstats -P ALL -F
memory allocated for index 0 ptr 0x624690
memory allocated for index 1 ptr 0x624ad0
memory allocated for index 2 ptr 0x624b00
memory allocated for index 3 ptr 0x624b30
memory allocated for index 4 ptr 0x624b60
memory allocated for index 5 ptr 0x624b90
memory allocated for index 6 ptr 0x624bc0
memory allocated for index 7 ptr 0x624bf0
memory allocated for index 8 ptr 0x624c20
memory allocated for index 9 ptr 0x624c50
attach for index 0 ptr 0x624690
attach for index 1 ptr 0x624ad0
attach for index 2 ptr 0x624b00
attach for index 3 ptr 0x624b30
attach for index 4 ptr 0x624b60
attach for index 5 ptr 0x624b90
attach for index 6 ptr 0x624bc0
attach for index 7 ptr 0x624bf0
attach for index 8 ptr 0x624690 --------------It seems this is pointing to first(0th index) now. So latter when we try to free it says double free as 0th index is already freed.
attach for index 9 ptr 0x624c50
And the root cause is show below.
@ eal.c
static int
eal_parse_args(int argc, char **argv)
{
int opt, ret;
char **argvopt;
int option_index;
char *prgname = argv[0];
const int old_optind = optind;
const int old_optopt = optopt;
char * const old_optarg = optarg;
int islocal_config = 0;
int num_para = 0;
argvopt = argv;
optind = 1;
while ((opt = getopt_long(argc, argvopt, eal_short_options,
eal_long_options, &option_index)) != EOF) {
…
if (optind >= 0) --- ● when call getopt_long the optind will ++ and at this case the optind is 9 at this time, so the argv[8] will be changed as argv[0]. This is the original DPDK code.
argv[optind-1] = prgname;
ret = optind-1;
out:
/* restore getopt lib */
optind = old_optind;
optopt = old_optopt;
optarg = old_optarg;
return ret;
}
My question is what the code below actually supposed to be used for? Thanks!
if (optind >= 0)
argv[optind-1] = prgname;
ret = optind-1;
------------------------------------
Shen Chuanpeng
Tel : 15858127547
Seat : 17066
------------------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-17 12:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 12:38 [dpdk-users] 【dpdk eal parameter parse issue check】 Shen, Chuanpeng (NSB - CN/Hangzhou)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).