tanlock
tanlock16mo ago

munmap_chunk() : invalid pointer error in client server code

Hello, I am doing a project on client server using socket programming in c++ using aes encryption and generating shared key using deffi hellman algo (crpto++ lib) but i am getting the following error. I have mentioned the erorr in image below … if code is needed I wld send it
how to solve this errro? is there any problem in socket programming? bcz when i am running my encryption part its printing the values of plain and vipher text correctly until it is retures and used as input for decryption
13 Replies
Cyber Forum
Cyber Forum16mo ago
Post created!
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord 🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Forum Profile" role in <id:customize> ✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution (if you don't see the option, try refreshing Discord with Ctrl + R)
From An unknown user
DirtyJ
DirtyJ16mo ago
That looks like something is being freed that isn't free-able. I'd recommend setting up a debugger and stepping through there to see where exactly that's happening. Valgrind is a pretty good tool for that on Linux
tanlock
tanlockOP16mo ago
Yes i started de bugging in steps … checked the produced public keys and private keys and the shared key generated is the same … I then tried dubugging the aes encryption function and its giving an correct output to of cipher text but when cipher text is returned and used in decryption there is this error
tanlock
tanlockOP16mo ago
For reference 😅
DirtyJ
DirtyJ16mo ago
If you have valgrind and GDB, you can remotely step through the code line by line until you hit the line that causes the error to occur https://valgrind.org/docs/manual/manual-core-adv.html
Valgrind
Official Home Page for valgrind, a suite of tools for debugging and profiling. Automatically detect memory management and threading bugs, and perform detailed profiling. The current stable version is valgrind-3.21.0.
tanlock
tanlockOP16mo ago
Oki wld try this first …
DirtyJ
DirtyJ16mo ago
Currently not at my PC, but I'll take a closer look tomorrow morning if you haven't figured it out by then
tanlock
tanlockOP16mo ago
Yes thankyou ✌️🫡 Hey have you found any solution to the error??
DirtyJ
DirtyJ16mo ago
Hey, didn't have a chance to check it out yesterday. Going to look after a meeting today I'm not seeing anything specific from scanning through that code that would cause it. Unless the socket is being closed twice or there's something weird happening to the server reference after it's typecasted and sent to connect(). Setting up a debugger and stepping through that logic is the best bet for finding the exact line/behavior that caused it without getting too much of a headache trying to figure it out in your head
tanlock
tanlockOP16mo ago
I know basic multithread client server programming and was trying to mix it up encryption and key generation … so you are saying there some problem in my socket programming part right? There is some problem*
DirtyJ
DirtyJ16mo ago
Could be, or it could be the way things are being handed to some of the functions being used. For example, if you hand something over to another function and it's freed in there, freeing it again will result in an error. Stepping through it will show you exactly where that's occurring
tanlock
tanlockOP16mo ago
Okay wld check that and ask if you if I am facing any problems further

Did you find this page helpful?