From: "Shen, Chuanpeng (NSB - CN/Hangzhou)" <chuanpeng.shen@nokia-sbell.com>
To: "users@dpdk.org" <users@dpdk.org>
Subject: [dpdk-users] 【dpdk eal parameter parse issue check】
Date: Thu, 17 Jan 2019 12:38:50 +0000 [thread overview]
Message-ID: <HE1PR0702MB35624F20053D9A1609F4D920DD830@HE1PR0702MB3562.eurprd07.prod.outlook.com> (raw)
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
------------------------------------
reply other threads:[~2019-01-17 12:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=HE1PR0702MB35624F20053D9A1609F4D920DD830@HE1PR0702MB3562.eurprd07.prod.outlook.com \
--to=chuanpeng.shen@nokia-sbell.com \
--cc=users@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).