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

  Рет қаралды 31,744

Mike Shah

Mike Shah

Күн бұрын

Пікірлер: 45
@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!
@MrNaderz
@MrNaderz 3 жыл бұрын
You're a great educator Mike
@MikeShah
@MikeShah 3 жыл бұрын
Thank you Salim!
@JackSparrow-tt3xg
@JackSparrow-tt3xg 7 ай бұрын
Professionals Use : GDB Legends use : printfs logs
@MikeShah
@MikeShah 7 ай бұрын
🤣 Sometimes all you have is printf :)
@stepside6874
@stepside6874 Жыл бұрын
Thank you so much. It helps me a lot.
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@shawnkuo6566
@shawnkuo6566 5 ай бұрын
Seriously, how do you resize the left half screen at 5:54 ?
@MikeShah
@MikeShah 5 ай бұрын
Check out my tmux tutorial: kzbin.info/www/bejne/bpfdp4OwarVjh5Y (Around the 3 minute mark I show you how to move and split windows)
@amitrastogi1405
@amitrastogi1405 11 ай бұрын
Excellent Video. Thanks!
@MikeShah
@MikeShah 11 ай бұрын
Cheers!
@parul9455
@parul9455 2 ай бұрын
After adding printf, why memory allocated is 1056 bytes, earlier it was 32 bytes
@MikeShah
@MikeShah 2 ай бұрын
timestamp? I suspect printf allocates, or at least on first use could allocate memory.
@sallaklamhayyen9876
@sallaklamhayyen9876 Жыл бұрын
Thank you So Mike you are a great teacher by NATURE 😘
@MikeShah
@MikeShah Жыл бұрын
Cheers, thank you for the kind words!
@saranshgautam3011
@saranshgautam3011 6 ай бұрын
nice tutorial. very helpful!
@MikeShah
@MikeShah 6 ай бұрын
Cheers!
@eddyecko94
@eddyecko94 Жыл бұрын
Thanks. I’m a C++ guy but I like this
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@paulfloyd9258
@paulfloyd9258 11 ай бұрын
Even more fun (for users): using valgrind vgdb and gdb together.
@MikeShah
@MikeShah 11 ай бұрын
Cheers -- agreed!
@shaharrefaelshoshany9442
@shaharrefaelshoshany9442 3 жыл бұрын
AMAZING !! best explanation
@MikeShah
@MikeShah Жыл бұрын
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!
@sallaklamhayyen9876
@sallaklamhayyen9876 Жыл бұрын
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 Жыл бұрын
Will consider developing something in the future :)
@sallaklamhayyen9876
@sallaklamhayyen9876 Жыл бұрын
@@MikeShah thank you for your time and efforts
@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 Жыл бұрын
How to check vptr and v table in c++
@MikeShah
@MikeShah Жыл бұрын
info vtbl will do the trick. I show some of this on my "Hands on Debugging" course on courses.mshah.io/
@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 :)
@vkatasonov
@vkatasonov 6 ай бұрын
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 6 ай бұрын
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 6 ай бұрын
@@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 6 ай бұрын
@@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 6 ай бұрын
@@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
@Quancept
@Quancept Жыл бұрын
thanks Mike :)
@MikeShah
@MikeShah Жыл бұрын
You are most welcome!
@HsuChiChen
@HsuChiChen 3 жыл бұрын
thx a lot!!
@MikeShah
@MikeShah Жыл бұрын
Cheers!
C Dynamic Memory Debugging with Valgrind
17:51
Brian Fraser
Рет қаралды 135 М.
you need to stop using print debugging (do THIS instead)
7:07
Low Level
Рет қаралды 456 М.
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 99 МЛН
小路飞和小丑也太帅了#家庭#搞笑 #funny #小丑 #cosplay
00:13
家庭搞笑日记
Рет қаралды 10 МЛН
Software Development with C++: Debugging with Valgrind
17:26
CoffeeBeforeArch
Рет қаралды 4,7 М.
Debugging with Core Dumps
9:16
Jacob Sorber
Рет қаралды 66 М.
Finally Fix Your Issues With JS/React Memory Management 😤
20:13
Jack Herrington
Рет қаралды 88 М.
How They Hack: Buffer Overflow & GDB Analysis - James Lyne
16:06
find memory errors quickly. (-fsanitize, addresssanitizer)
9:44
Jacob Sorber
Рет қаралды 19 М.
Compile from Source - Build Latest GDB and Binutils on Linux
13:14
Fix Memory Leaks in C Code with Valgrind
11:09
NeuralNine
Рет қаралды 37 М.
Tom Ziemke, EI'23 Conference
15:37
AgriFoRwArdS CDT YouTube Channel
Рет қаралды 33
From Small To Giant 0%🍫 VS 100%🍫 #katebrush #shorts #gummy
00:19