I am working on Linux. In which section of memory are the command line arguments stored (stack or heap)?
I tried to execute free(argv) and I got a segmentation fault. Why is that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can only
freewhat youmalloc/calloc(and possiblyrealloclater on). Trying tofreesomething else invokes Undefined Behaviour. One (good) way UB manifests itself is by producing a segmentation fault; a (bad) way is to make the program appear to work as intended.As to where they are … read section 5.1.2.2.1 of the C99 Standard — its unspecified.