0

I have completed my first draft of pset6 web server and I have used valgrind to check my program for memory leaks of which there seem to be none. However, when I ran my server.c file through check50 I get the following error message: enter image description here

My file name is server.c as the instructions for the pset6 have specified. The error seems to be pointing to my load function but I don't understand why it is displaying a reference to server4.c? Any help with this problem would be much appreciated.

8
  • If I had a nickle for every time I made changes to a program and forgot to compile....:) I would take the error at face value, your server doesn't compile. I suspect the reference to "server4" is part of check50 secret sauce. Re: valgrind, make sure you send a request before you ^C out of valgrind. It will always be clean if it has not processed a request. Commented Aug 6, 2016 at 19:48
  • After I made changes my program I actually did compile it when I ran it through the IDE window but when running check50 it dosen't show that, as you can see above. What do you mean by secret sauce and what do you mean by sending a request before quitting valgrind? Commented Aug 7, 2016 at 16:23
  • I don't know why check50 wouldn't compile your program if it compiled on the IDE. Unless... did you make any changes to server outside the prescribed functions? By secret sauce, I mean, check50 creates it's own "environment" so maybe it loads the submitted source to a file named "server4.c". Pure speculation. After you start server under valgrind, you need to send a browser request, or a curl request from another terminal. That way it will execute your functions. Then when you quit valgrind, it will report errors if found. Commented Aug 7, 2016 at 16:31
  • I've thoroughly checked the server outside of the prescribed functions and nothing has been altered. I am quite new to programming and keen to learn , so forgive me if I seem to be asking you what are probably obvious questions to you. How do you start the server under valgrind and how do you send the browser a request whilst running valgrind? Commented Aug 8, 2016 at 12:32
  • Slow and steady wins the race :) Just to verify, actually did compile it when I ran it through the IDE window means you ran make server? What result do you get if you run make server now? (I will definitely answer your valgrind question, just establishing a baseline). Commented Aug 8, 2016 at 12:51

1 Answer 1

0

I checked my code at line 680 and removed the free(buffer) from my load function. Now my program compiles in the IDE window and in check50 but with all of the requests in red, below:

server.c compiles with errors

I also ran server.c with valgrind and got the following errors too:

valgrind errors

Correct me if I am wrong but there seems to be problems with lines 744, 747 and 750 in the parse function of my code, which are causing the memory leaks. I think that valgrind is suggesting that the code has been written incorrectly? I would appreciate it if you could point me in the right direction on this. Thanks for your continuing help.

1
  • yes that's where to start (744, 747, 750). The "invalid write of size 1" could indicate allocation that does not consider null-terminator. And remember "expected output, not an exit code of 0" is a seg fault, probably in the query area of parse. gdb will help you, find some tips here Commented Aug 8, 2016 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .