View Issue Details

IDProjectCategoryView StatusLast Update
0005137GNUnetotherpublic2018-06-07 00:24
ReporterPeter Jankuliak Assigned Tonikita  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Summary0005137: argv should not be explicitly freed
DescriptionI noticed this in several c files which have the 'main' function.

E.g. here

https://gnunet.org/git/gnunet.git/tree/src/cadet/gnunet-cadet.c?id=37d4b1f14ebc692efe9a2744946ba2bfd8ccf6d3#n985

https://gnunet.org/git/gnunet.git/tree/src/vpn/gnunet-vpn.c?id=37d4b1f14ebc692efe9a2744946ba2bfd8ccf6d3#n346

Unfortunately, I am unable to find a C reference specification where they explicitly mention that it should not be freed, but I have never seen it done in any projects I've ever worked on (see e.g. the example section in `man execve` [0]) and posts such as these [1] [2] [3] suggest that it results in unspecified behavior:


[0] https://linux.die.net/man/2/execve
[1] https://stackoverflow.com/questions/34619558/is-it-required-to-free-or-delete-the-arguments-passed-into-main-in-c/34619581
[2] https://stackoverflow.com/questions/26416678/where-does-the-os-store-argv-and-argc-when-a-child-process-is-executed
[3] https://stackoverflow.com/questions/25850285/memory-allocation-and-argv-argument
TagsNo tags attached.

Activities

Peter Jankuliak

2017-09-20 10:53

reporter   ~0012428

Ah, I spoke too soon. I missed the fact that the function GNUNET_STRINGS_get_utf8_args overwrites argv.

Peter Jankuliak

2017-09-20 13:40

reporter   ~0012429

Sorry for the noise, feel free to close this non-issue.

nikita

2017-09-24 12:45

reporter   ~0012431

Thanks for the report, even if it's a non-issue.
So by your own findings it can be closed as resolved?

Peter Jankuliak

2017-09-24 13:44

reporter   ~0012433

> So by your own findings it can be closed as resolved?

Yes please.

Issue History

Date Modified Username Field Change
2017-09-20 10:21 Peter Jankuliak New Issue
2017-09-20 10:53 Peter Jankuliak Note Added: 0012428
2017-09-20 13:40 Peter Jankuliak Note Added: 0012429
2017-09-24 12:44 nikita Assigned To => nikita
2017-09-24 12:44 nikita Status new => acknowledged
2017-09-24 12:45 nikita Note Added: 0012431
2017-09-24 12:45 nikita Status acknowledged => feedback
2017-09-24 13:44 Peter Jankuliak Note Added: 0012433
2017-09-24 13:44 Peter Jankuliak Status feedback => assigned
2017-09-24 14:08 nikita Status assigned => resolved
2017-09-24 14:08 nikita Resolution open => fixed
2018-06-07 00:24 Christian Grothoff Status resolved => closed