View Issue Details

IDProjectCategoryView StatusLast Update
0005137GNUnetotherpublic2018-06-06 22:24
ReporterPeter Jankuliak Assigned Tonikita Due Date
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 08: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 11:40

reporter   ~0012429

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

nikita

2017-09-24 10: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 11:44

reporter   ~0012433

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

Yes please.

Issue History

Date ModifiedUsernameFieldChange
2017-09-20 08:21Peter JankuliakNew Issue
2017-09-20 08:53Peter JankuliakNote Added: 0012428
2017-09-20 11:40Peter JankuliakNote Added: 0012429
2017-09-24 10:44nikitaAssigned To => nikita
2017-09-24 10:44nikitaStatusnew => acknowledged
2017-09-24 10:45nikitaNote Added: 0012431
2017-09-24 10:45nikitaStatusacknowledged => feedback
2017-09-24 11:44Peter JankuliakNote Added: 0012433
2017-09-24 11:44Peter JankuliakStatusfeedback => assigned
2017-09-24 12:08nikitaStatusassigned => resolved
2017-09-24 12:08nikitaResolutionopen => fixed
2018-06-06 22:24Christian GrothoffStatusresolved => closed