[CRIU] [PATCH 2/2] config: Don't free memory in PARSING_USER_CONF
Radostin Stoyanov
rstoyanov1 at gmail.com
Sun Jan 20 00:00:14 MSK 2019
On 19/01/2019 18:11, Radostin Stoyanov wrote:
> On 19/01/2019 17:23, Radostin Stoyanov wrote:
>> On restore, when state=PARSING_USER_CONF the _argv pointer
>> points to the location which contains the envirnment variables
>> and should not be free()-ed.
>>
>> Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
>> ---
>> criu/config.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/criu/config.c b/criu/config.c
>> index 89afdd748..f3c8d4254 100644
>> --- a/criu/config.c
>> +++ b/criu/config.c
>> @@ -509,7 +509,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
>> /* Only if opt is -1 we are going to the next configuration input */
>> if (opt == -1) {
>> /* Do not free any memory if it points to argv */
>> - if (state != PARSING_ARGV + 1) {
>> + if (state != PARSING_ARGV + 1 && state != PARSING_USER_CONF) {
>> int i;
>> for (i=1; i < _argc; i++) {
>> free(_argv[i]);
> I sent this patch because I am getting the error:
>
> (00.000000) Unable to get $HOME directory, local configuration file will
> not be used.
> (00.000014) Warn (criu/log.c:203): The early log isn't empty
> (00.000022) Version: 3.11 (gitid
> v3.11-125-g93043916c)
>
> On Arch Linux with kernel version 5.0.0-rc2-g6b529fb0a3ea
> However, I just noticed that the error does not reproduce on Fedora 29.
> I will continue to investigate.
>
It does not seem to be a kernel issue because I'm getting the same error
with 4.20.3 on Arch.
The interesting part is that /etc/criu/default.conf is an empty file and
with the following info statements
diff --git a/criu/config.c b/criu/config.c
index b6ecbfb64..7cd3bbec0 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -512,6 +512,7 @@ int parse_options(int argc, char **argv, bool
*usage_error,
if (state != PARSING_ARGV + 1) {
int i;
for (i=1; i < _argc; i++) {
+ pr_info("%s\n", _argv[i]);
free(_argv[i]);
}
free(_argv);
@@ -520,7 +521,9 @@ int parse_options(int argc, char **argv, bool
*usage_error,
_argc = 0;
_argv = NULL;
+ pr_info("> state=%d _argv=%p\n", state, _argv);
state = next_config(argv, &_argv,
no_default_config, state, cfg_file);
+ pr_info(">> state=%d _argv=%p\n", state, _argv);
/* if next_config() returns 0 it means no more
configs found */
if (state == 0)
@@ -530,6 +533,7 @@ int parse_options(int argc, char **argv, bool
*usage_error,
continue;
_argc = count_elements(_argv);
+ pr_info(">> _argc=%d\n", _argc);
optind = 0;
}
The log file is:
(00.000000) > state=1
_argv=(nil)
(00.000000) >> state=2
_argv=0x563a5786cda0
(00.000000) >>
_argc=10
(00.000000)
XAUTHORITY=/run/user/1000/gdm/Xauthority
(00.000000)
LANG=en_GB.UTF-8
(00.000000)
TERM=xterm-256color
(00.000000)
DISPLAY=:0
(00.000000)
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/go/bin:/home/rst/Projects/bin:/home/rst/Projects/src/k8s.io/kubernetes/third_party/etcd
(00.000000)
MAIL=/var/mail/root
(00.000000)
LOGNAME=root
(00.000000)
USER=root
(00.000000)
HOME=/root
(00.000000) > state=2
_argv=(nil)
(00.000000) Unable to get $HOME directory, local configuration file will
not be used.(00.000000) >> state=3 _argv=(nil)
(00.000000) > state=3
_argv=(nil)
(00.000000) >> state=4
_argv=(nil)
(00.000000) > state=4
_argv=(nil)
(00.000000) >> state=5
_argv=(nil)
(00.000031) Warn (criu/log.c:203): The early log isn't
empty
(00.000036) Version: 3.11 (gitid v3.11-125-g93043916c)
Radostin
More information about the CRIU
mailing list