Using Valgrind and GDB together to fix a segfault and memory leak

  Рет қаралды 32,337

Mike Shah

Mike Shah

Күн бұрын

Пікірлер: 47
@ricktierney6508
@ricktierney6508 Жыл бұрын
Thank you for this explanation! You are a great teacher and this helped me fix my memory leak in one hour instead of one week
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@shawnkuo6566
@shawnkuo6566 6 ай бұрын
Seriously, how do you resize the left half screen at 5:54 ?
@MikeShah
@MikeShah 6 ай бұрын
Check out my tmux tutorial: kzbin.info/www/bejne/bpfdp4OwarVjh5Y (Around the 3 minute mark I show you how to move and split windows)
@MrNaderz
@MrNaderz 3 жыл бұрын
You're a great educator Mike
@MikeShah
@MikeShah 3 жыл бұрын
Thank you Salim!
@parul9455
@parul9455 3 ай бұрын
After adding printf, why memory allocated is 1056 bytes, earlier it was 32 bytes
@MikeShah
@MikeShah 3 ай бұрын
timestamp? I suspect printf allocates, or at least on first use could allocate memory.
@tweetyguy7347
@tweetyguy7347 Ай бұрын
@@MikeShahit’s at the very end of the video
@MikeShah
@MikeShah Ай бұрын
@@tweetyguy7347 It seems that in printf (which is a call to vfprintf) there are several calls to malloc (example implementation: github.com/lattera/glibc/blob/master/stdio-common/vfprintf.c) -- so I suspect somewhere there's a buffer of 1024 bytes that must get allocated.
@stepside6874
@stepside6874 Жыл бұрын
Thank you so much. It helps me a lot.
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@amitrastogi1405
@amitrastogi1405 Жыл бұрын
Excellent Video. Thanks!
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@sallaklamhayyen9876
@sallaklamhayyen9876 2 жыл бұрын
Thank you So Mike you are a great teacher by NATURE 😘
@MikeShah
@MikeShah 2 жыл бұрын
Cheers, thank you for the kind words!
@saranshgautam3011
@saranshgautam3011 7 ай бұрын
nice tutorial. very helpful!
@MikeShah
@MikeShah 7 ай бұрын
Cheers!
@_Anna_Nass_
@_Anna_Nass_ 2 жыл бұрын
Do you have a video that covers what you did in the first few seconds of this video? I understand the C code and why we got a seg fault but I'm not as familiar with the Linux command line.
@MikeShah
@MikeShah 2 жыл бұрын
Ah, as far as the terminal goes, check out: the Terminal Masterclass in this playlist: kzbin.info/aero/PLvv0ScY6vfd-GGT-aUH31X2yXgBSYXo6t
@_Anna_Nass_
@_Anna_Nass_ 2 жыл бұрын
@@MikeShah will do, thanks!
@shaharrefaelshoshany9442
@shaharrefaelshoshany9442 3 жыл бұрын
AMAZING !! best explanation
@MikeShah
@MikeShah 2 жыл бұрын
Cheers!
@JackSparrow-tt3xg
@JackSparrow-tt3xg 9 ай бұрын
Professionals Use : GDB Legends use : printfs logs
@MikeShah
@MikeShah 9 ай бұрын
🤣 Sometimes all you have is printf :)
@eddyecko94
@eddyecko94 Жыл бұрын
Thanks. I’m a C++ guy but I like this
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@vkatasonov
@vkatasonov 7 ай бұрын
Hello, Mike. I wanted to ask if you having some problems using leaks on Mac 💻 with M chip? I was trying to use memory leaks monitoring using methods you were speaking about in other videos, but it seems with Sonoma I don’t have access to usr/bin 🤷‍♂️
@MikeShah
@MikeShah 7 ай бұрын
I can't remember if in that video I elevated my privileges to super user (sudo or su). That may have been necessary, or otherwise is one thing you can try. There's probably a better fix though than to have to get elevated priveleges -- though that is something I'll have to test when I upgrade my Mac.
@vkatasonov
@vkatasonov 7 ай бұрын
@@MikeShah Thx a lot, if you will have answer to this issue I would be very appreciate. I'm trying to solve this problem as soon as I'm passing a huge course of C programming and that tool was absolutely magic for me. Everytime I run leaks --atExit-- , I have that crazy 2185 segmentation fault sudo leaks --atExit-- . I was trying to switch off SIP, but it still doesn't work. And it seems that $PATH I have introduce correctly because there is leaks tool in the system which leaks /usr/bin/leaks
@MikeShah
@MikeShah 7 ай бұрын
@@vkatasonov Worse case if you can use a VM on valgrind that should immediately reveal answers. Otherwise, this may be a helpful post in regards to Mac and Sonoma: forums.developer.apple.com/forums/thread/738804
@vkatasonov
@vkatasonov 7 ай бұрын
@@MikeShah I was trying to use VM on UTM but valgrind there doesn’t work. The only solution I see is Docker with Linux or idx from google
@CarlosLeePerez
@CarlosLeePerez 3 жыл бұрын
I have two follow up questions about Valgrind. I am currently having difficulty getting to the stage you are on, thanks to my Linux Lite naivete. How would you recommend, I create the right environment on Linux Lite to go from merely having Valgrind installed to allowing the terminal to recognize the valgrind command, which you used? Secondly, is my asking this sort of question here in the comments a good way of reaching out to you?
@MikeShah
@MikeShah 3 жыл бұрын
Hi Carlos, yes comments are a good way to reach out, I try to give one response to as many as I can--though cannot debug 1:1 with folks :) If Ubuntu is an option, that'll setup the environment right away. If you're constrained to Linux Lite, then my guess is you're missing some base packages or dependencies for Valgrind. I'd reach out directly through their contact otherwise: www.valgrind.org/downloads/current.html
@matheens6689
@matheens6689 2 жыл бұрын
How to check vptr and v table in c++
@MikeShah
@MikeShah 2 жыл бұрын
info vtbl will do the trick. I show some of this on my "Hands on Debugging" course on courses.mshah.io/
@paulfloyd9258
@paulfloyd9258 Жыл бұрын
Even more fun (for users): using valgrind vgdb and gdb together.
@MikeShah
@MikeShah Жыл бұрын
Cheers -- agreed!
@sallaklamhayyen9876
@sallaklamhayyen9876 2 жыл бұрын
Mike since you are a professional C++ developer can you make a practical and hands on Object Oriented programming course and share with us your experience ?
@MikeShah
@MikeShah 2 жыл бұрын
Will consider developing something in the future :)
@sallaklamhayyen9876
@sallaklamhayyen9876 2 жыл бұрын
@@MikeShah thank you for your time and efforts
@Quancept
@Quancept Жыл бұрын
thanks Mike :)
@MikeShah
@MikeShah Жыл бұрын
You are most welcome!
@cprn.
@cprn. 2 жыл бұрын
I'm disappointed you didn't mention you can run `valgrind --vgdb=yes` and connect gdb to valgrind.
@MikeShah
@MikeShah 2 жыл бұрын
Will have to be another video :)
@HsuChiChen
@HsuChiChen 3 жыл бұрын
thx a lot!!
@MikeShah
@MikeShah 2 жыл бұрын
Cheers!
C Dynamic Memory Debugging with Valgrind
17:51
Brian Fraser
Рет қаралды 135 М.
Debugging with Core Dumps
9:16
Jacob Sorber
Рет қаралды 66 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
you need to stop using print debugging (do THIS instead)
7:07
Low Level
Рет қаралды 462 М.
We can now write scripts using these languages, but is it worth it?
8:28
How to Crack Software (Reverse Engineering)
16:16
Eric Parker
Рет қаралды 834 М.
find memory errors quickly. (-fsanitize, addresssanitizer)
9:44
Jacob Sorber
Рет қаралды 19 М.
Finally Fix Your Issues With JS/React Memory Management 😤
20:13
Jack Herrington
Рет қаралды 89 М.
How computer processors run conditions and loops
17:03
Core Dumped
Рет қаралды 181 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 338 М.
Mastering Memory Management in Node.js: Tips and Tricks for Better Performance
16:06
Software Developer Diaries
Рет қаралды 40 М.
Memory leaks and how to prevent them
10:49
CodeVault
Рет қаралды 25 М.
How to Inspect Compiled Binaries (binutils, objdump)
7:53
Jacob Sorber
Рет қаралды 44 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН