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

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

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!
@JackSparrow-tt3xg
@JackSparrow-tt3xg 7 ай бұрын
Professionals Use : GDB Legends use : printfs logs
@MikeShah
@MikeShah 7 ай бұрын
🤣 Sometimes all you have is printf :)
@MrNaderz
@MrNaderz 3 жыл бұрын
You're a great educator Mike
@MikeShah
@MikeShah 3 жыл бұрын
Thank you Salim!
@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)
@paulfloyd9258
@paulfloyd9258 11 ай бұрын
Even more fun (for users): using valgrind vgdb and gdb together.
@MikeShah
@MikeShah 11 ай бұрын
Cheers -- agreed!
@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.
@stepside6874
@stepside6874 Жыл бұрын
Thank you so much. It helps me a lot.
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@amitrastogi1405
@amitrastogi1405 11 ай бұрын
Excellent Video. Thanks!
@MikeShah
@MikeShah 11 ай бұрын
Cheers!
@sallaklamhayyen9876
@sallaklamhayyen9876 Жыл бұрын
Thank you So Mike you are a great teacher by NATURE 😘
@MikeShah
@MikeShah Жыл бұрын
Cheers, thank you for the kind words!
@eddyecko94
@eddyecko94 Жыл бұрын
Thanks. I’m a C++ guy but I like this
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@_Anna_Nass_
@_Anna_Nass_ Жыл бұрын
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 Жыл бұрын
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_ Жыл бұрын
@@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
@saranshgautam3011
@saranshgautam3011 6 ай бұрын
nice tutorial. very helpful!
@MikeShah
@MikeShah 6 ай бұрын
Cheers!
@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
@shaharrefaelshoshany9442
@shaharrefaelshoshany9442 3 жыл бұрын
AMAZING !! best explanation
@MikeShah
@MikeShah Жыл бұрын
Cheers!
@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 :)
@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/
@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 М.
Debugging with Core Dumps
9:16
Jacob Sorber
Рет қаралды 66 М.
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 19 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,3 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 328 М.
you need to stop using print debugging (do THIS instead)
7:07
Low Level
Рет қаралды 455 М.
CppCon 2016: Greg Law “GDB - A Lot More Than You Knew"
59:09
How to Inspect Compiled Binaries (binutils, objdump)
7:53
Jacob Sorber
Рет қаралды 43 М.
How to get a junior graphics engineer job [Mike's Advice]
13:26
Mike Shah
Рет қаралды 1,3 М.
Advanced C: The UB and optimizations that trick good programmers.
1:12:34
Eskil Steenberg
Рет қаралды 176 М.
GDB Debugging: How to Debug a C/C++ program
18:07
pikuma
Рет қаралды 38 М.
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 19 МЛН