Surprise Me!

x86-64 Assembly Segfault on printf? Fix Stack Alignment (Yasm + GCC Demo)

2025-11-16 3 Dailymotion

Your x86-64 assembly program looks correct, links with GCC, calls printf, and then crashes with a segfault. This video shows exactly why it happens and how to fix it.<br /><br />We build a hybrid program using Yasm and GCC on Linux, print a message from C++, call an assembly function, and hit the crash. Then we fix it with a push and pop of RAX, move the fix into the function prologue and epilogue, and run experiments to prove it works.<br /><br />No long lectures, just code, a real crash, and a real solution that stops the problem for good.<br /><br />Introduction 00:00:00<br />Hybrid Programs 00:00:09<br />Stack Alignment Problem 00:00:33<br />GCC Stack Expectations 00:01:14<br />Makefile Overview 00:02:22<br />Driver Code 00:03:16<br />Assembly Module Setup 00:04:12<br />Calling printf 00:05:20<br />Program Crash Demo 00:07:17<br />Diagnosing Segfault 00:07:56<br />Fix with Push-Pop 00:09:08<br />Prologue Epilogue Fix 00:11:18<br />Experiments Confirm 00:12:54<br />Conclusion 00:13:32<br />Outro Thanks 00:13:52<br /><br />Thanks for watching!<br /><br />Find us on other social media here:<br />- https://www.NeuralLantern.com/social<br /><br />Please help support us!<br /><br />- Subscribing + Sharing on Social Media<br />- Leaving a comment or suggestion<br />- Subscribing to our Blog<br />- Watching the main "pinned" video of this channel for offers and extras

Buy Now on CodeCanyon