strace feels like magic - let’s fix that (with Rust)
HTML-код
- Опубликовано: 29 июл 2024
- Follow me on Mastodon: hachyderm.io/@fasterthanlime
Support me on Patreon or GitHub: fasterthanli.me/donate
You can find the code at: github.com/fasterthanlime/rue
How to build a Rust service with Nix (new series): fasterthanli.me/series/buildin...
Contents
00:00 What is a full-stack engineer?
00:48 What's a syscall?
03:38 Tracing cat
05:43 Should strace work? Let's think security
07:14 Sponsor (wink wink)
08:21 How is a process created?
10:36 Trace me! Trace meeee
12:10 ptrace 101
13:15 Ok but seriously, what's a syscall?
14:00 We're ready to make an strace-like
15:10 Thanks to my patrons & sponsors
15:50 Surely no one watches this far Наука
Code for this video is here: github.com/fasterthanlime/rue
But if you want a real strace-like in Rust, look up lib.rs/crates/lurk-cli
Code in the repo is not the latest version shown in the video
@@thomasq5186 it wasn't indeed, I've just pushed the missing changes.
@@fasterthanlime thank you :) would you accept PRs in that repo or are these video projects done when the video is published?
@@thomasq5186 the repo should reflect the state of the project as built in the video - but I'm happy to link to forks that do interesting things!
Please never stop making content. The content out there for intermediate/advanced engineers that are past building tutorials is somewhat scarce, you provide a great niche in people wanting to gain even deeper understanding. Thank you!
I swear, when my braind heard you say the phrase "And this is why, in a lot of my content, I use the tool...", it automatically thought it was a segue into a bit about the sponsor of the video 😄
Great video, the production quality is amazing. Thanks for passing on this low-level knowledge!
This is really well produced. I generally prefer reading articles and don't usually watch programming videos but wow, this one has changed my mind. Thanks for making this, I learned a lot.
This is high praise, thanks so much!
Hysterical, your articles are already pretty funny but you're a great editor and personality too. I think this is one of your best
Thanks so much, this means a lot. People tend to say "I can't absorb technical content in video form" and while for some that may be true, I think for others I simply wasn't trying hard enough 🧐
@@fasterthanlime Yeah, when it's this well presented, it can be absorbed ;) You explain a tad too fast, but nothing that a few pauses or rewinds can't solve. Very cool content as always dude!
Hey Amos! Loved the video. As someone who has been working as a systems engineer for almost 9 years ( last 4 moved me into the software side) I am consistently amazed at how easy to digest you make very technical topics!
I’ve only found your channel about a week ago and I am slowly working through your back catalogue of both videos and articles. Your “sponsored by” spot was excellent and it reminded my to go sponsor on patreon. The enjoyment and inspiration you have given me is worth more than any other subscription I currently pay for! Keep up the great work.
Thanks so much for the kind words and enjoy!
The quality of your videos becomes more and more INSANE.
I am just in awe about how you do it. I made peace with you being a better coder than I am, but you being this good of an editor, that's just hard to swallow
I appreciate that your strace has colors. It's like going from cURL to httpie. They do basically the same things, but one is much prettier.
Yeah I didn't really explain that part in the video, and it wasn't in my initial research version, but lib.rs/crates/owo-colors makes it so easy to add colors, I couldn't resist! Makes the video a bit more readable, too.
every day, i learn of new epic programs
@@fasterthanlime whats better?
owo-colors
or colored
ive recently started a project where i used the latter
how does owo-colors compare to colored
@@RenderingUser iirc colored is dead (still works though) so owo-colors
@@hmmmyessssssss7270 rust programs are never dead, they are complete
When I was young I was writing random urls in my diary, kind of like I had my own index. I think I had somewhere between 5000 urls mostly collected from newspapers. Early signs are always there.
humorous and informative, best combo, thank you so much for these videos!
also the Straße joke was really ... albern. :D
According to my analytics, Germany is the country with the 2nd most viewers on my channel, so you can expect more dubious German jokes. As a Swiss-French (and a fellow European) I feel like they're fair game 🧐
@@fasterthanlime Sure thing, I hope I didn't come across as rude, I appreaciate all kinds of jokes :)
@@Cornyfisch no worries! My content is full of pretty silly jokes. It makes intimidating concepts a bit more approachable and help with pacing.
@@fasterthanlime As a matter of fact, i would vastly enjoy videos peppered by cross-language puns, since i understand at least a little of most European languages (excluding Basque, Hungarian and Finnish). Americans will be so pissed off though. Is it worth it?
I love how indepth your videos are!
Also: The editing on this video is really good with the strace output
Your videos are really well made + edited, not to mention the information you give is helpful. Fills a void that very few others fill. Thanks a lot for doing this (you also earned a sub)
The speed of the of the video together with the sound effects is just exactly right for me. Thank you!
You make an awesome job!
Very good explanation of what happens during program execution and what the kernel actually does in this context.
I love it!
I could never judge you bear. really cool video, gonna have to go over it a few times to really understand but this is complex stuff so that's okay. Also excellent editing! well done!
Love the sound work in this one!
Thanks! It's something I'm trying to get better at :)
I cannot express how much I enjoy watching your content, please keep it up!
Absolutely great content! Thank you for the work and ideas you put in
The increasing quality of your videos is pretty amazing, great job!
LOL, Amos! Very good quality editing and jokes.
You packed this video with a lot less information than I expected, yet it still felt a bit overwhelming. Maybe because of the mayhem... but that was also the fun part x)
Really enjoyed this video, gave me flashbacks to my os course back in uni
I was laughing way too much about the Straße joke. Well played 😂
oh that was a joke? (I thought it was just facts, because I don't speak German.) :facepalm:
@@recklessroges I mean the joke here is that a German person not knowing English would likely pronounce it this way. At least that's how I understood it as a German.
another perfect video thanks amos! 👏
Awesome stuff!!
I wanted to work on my side project but the video was too interesting. Really really good videos!
that end joke lmao (very good video! thanks amos!)
I've learned more here than one semester's worth of classes in my university, you are very skilled in explaining.
Thank you!
Then you need to find a better university!! I mean.. thank you very much, glad it helped!
How do you keep pumping up such top tier content? Absolute machine!
I am really happy that I found this channel :)
The end of videos feels like marvel after credits scenes. It's awesome. Your content is awesome.
Great content as always.
Thanks!
Read some of your blogs that show up in TWIR which are always fun, didn’t know you for RUclips videos too
very interesting video, keep it up!
Commenting for the algo yeehaw - awesome content !🎉 Going to pass this on to some of my students - especially the part about fullstack engineering
May the algorithm notice that I'm engaging with my audience. (Also I hope your students like it!)
@@fasterthanlime they've been loving your content as deep dives into Rust concepts!
Great to see nix-profile in there ;)
Haha yes, I noticed it too while editing and thought it would be a nice teaser - but then it's during that video that I've announced a 12-part article series about nix!
Great upload rate! Keep it up =)
Get that bread!
🍞🍞🍞 thank you so much!!
I am full stack: I digged out the iron ore myself, smelted it into a computer with relays. Then coded the network code and the spam server on it myself in machine code.
Didn't expect this quality when clicking on the video
Better this than the other way around tbh
Fixedly Staring Amos isn't real, he can't hurt you
Fixedly Staring Amos: 15:27
(Have been loving this content, like others said, so great to have approachable videos but on advanced topics; I feel a lot less scared of computers now)
Miguel I don't believe you were ever scared of computers.
@@fasterthanlime I'm sure that if I keep learning about computers I can be more scared of them than ever 😊
When I first saw full-stack engineer I was like, oh boi here we go again, and then you said it was unrealistic and didn't exist, I knew I had to stay to listen to more you had to say
Terrific
LMAO "We love you baby, get that 🍞" 😂
I hope the implication at the end was you're making that memory usage tracer, because that'd be pretty handy
Very nice video!
Is the "is_sys_exit" toggle really the correct way? It looks a bit hacky.
How does it handle multi-thread applications?
Does ptrace really stop all threads simultaneously?
Great questions! The boolean is the cheap/fast way of doing it. There's mechanisms to query why the program stopped, but they're more expensive/slower than just keeping track yourself.
Re multithreading: I did say "threads = processes" (on Linux) and it's particularly visible with pthread. Each thread is a separate tracee and can have a separate tracer. ptrace can notify you when clones happen, which works for both starting children processes and starting new threads.
Wow this is very high quality - til about strace!
I've learned so much through just using strace on stuff. We have better tools for that now but.. that'll have to wait for another video!
Ok I love this content
Rust and Nix? Oh goodie... Gonna look it up right away. Gute Besserung meanwhile 🖖🏿
Wait, protection rings are a CPU feature? Cool! I will now spend several hours researching this, thank you
So the Wikipedia page (serious research I know) mentions that NT & Linux kernels don't necessarily use that feature anymore, but they use the "supervisor/user" mode. I would have to reach out to an expert to make confident statement about the exact details.
@@fasterthanlime Interesting.
for some reason I thought it just loaded it's own glibc wrappers with LD_PRELOAD but that would not work if you were to call the syscalls manually instead of with glibc
Fun fact: Technically 'cat' program stands for concatenate and is used to concatenate multiple files. At least this is its original UNIX system purpose.
This whole time I thought it was C (see) And Talk.
@@raffimolero64 `man cat`:
`cat - concatenate files and print on the standard output`
@@raffimolero64 I didn't use UNIX system, but my guess is that in some UNIX guideline books for viewing files you would use `vi`, not `cat` :p Maybe `less`. In fact viewing files via `cat` is not very handy. `less` is far superior.
Fun fact: this was part of the original script and I cut it while editing the video, in an awe-inspiring act of self-control.
@@fasterthanlime That's hell of a fun fact!
Very cool
Great video as always. I would recommend veering away from the sound effects on the text scroll. It's a bit distracting.
"I guess there were signs--" 😂🤣
Very qualitative content here
Comment so that youtube recommends your great channel to all...
Great video as always Amos...
Subscribed. Obviously.!
Beautiful. BTW, Rust program that runs `cat` should be called `rat` 🐀. Like rat on syscalls 😀
We do that with many Rust portings but: Remote access trojan (RAT) is already a thing, (and really hard to google.)
Jesus christ, I’m becoming an addict of this channel…
Amazing content, perfect level of details and explanations, full of useful knowledge. Thank you!
Ps: Would you be willing some day to share your editing process? How you create animations, how you do the cuts, how you use the editing software, etc. As someone who is trying to start something similar, I realized how difficult this is…
I'm resisting the urge to make meta videos like these (the closest would be "This is a video about video") but I can confirm that it is indeed a lot of work.
I haven't found a great solution for motion graphics yet - I do most of it in DaVinci Resolve directly (rarely even using the Fusion tab). Sometimes I'll build a little thing in the browser to visualize something. I've been trying to find other tools better suited to what I want but none are tightly integrated into Resolve, making it a hassle.
Have you heard of motion canvas? It’s a 3blue1brown-esque animation software/video editor written in Typescript. There’s a video demonstration on RUclips. Might be useful
@@fasterthanlime Did the "make my own RUclips" experiment prove problematic? The video section on your site vanished.
Ya know I saw an article recently about some algorithm being able to calculate where given sequences of π show up, or something like that. Anyways at least you got a cool story to go with your neurosis, they just asked me to tutor HS freshmen in pre-algebra meh
Hey, what is the name of the theme you're using :) ?
It's GitHub Dark
fullstack engineer is who that can refine iron ore and silicon ,lithium and other imortant ore than mak tools to make machines to make circuite board and make energy genrator then make all ic and transistors and spreaker and wireless entwork and make dispay with light bulbs and make keyboard etc than write the kernel for it and then make opreating system and make desktop and make broswer with link to other computers with internet and able to make webstie on it an also design all this on figma is what i call the ultimate full stack
need myself a "Don't blame me, it's GNU code" shirt.
Your content is awesome. I've been watching all your videos since "C++ vs Rust: which is faster" and you never miss.
I did not expect myself be fully attentive throughout an entire technical video, and thanks to you I already did that thrice.
Keep up the good work!!
OH THERE WERE SIGNS ON SIGNS AMOS :D
😇
There were signs that you’d be a mad scientist. 😂
0:39 It was DNS.
❤️
Please upload a video on your hair care routine. they are really beautiful.
What do you mean "you can't trust the source code"; do you have links to any articles regarding that? Big fan!
This is somewhat tongue in cheek, but mostly I mean you can't trust your understanding of the code - are you even looking at the right code? Is the compiler doing something unexpected with it? (like if your code has unexpected behavior) etc.
The "actually" in "what actually happens" is the keyword here.
If you're looking into the security aspect of it, Ken Thompson's "Reflections on Trusting Trust" is a classic.
What is syscall on POWER or ARM?
It seems PowerPC has an "sc" isntruction, and arm64 does "svc #0", cf. stackoverflow.com/a/38906005
And RISC-V has `ecall`
10:20 Yes you did use it right, also you have reminded me I haven't visited r/LiminalSpace in a while. Off to... uhm... be liminal? Edit: Actually I will finish the video
haha if you are german straße :) Love it
This shit is fire
> Oh no
Indeed.
ha, just started strace log parser for fun. wondered if I could just rewrite strace in the end.
There's something very satisfying about being able to move from "scripts that parse the output of Linux system tools" to "directly interfacing with those facilities" - it's not always the strategic thing to do if you're trying to get results quickly, but you do learn a lot!
Keep in mind that multithreading hasn't been covered at all in this video, whereas strace does handle that case properly.
@@fasterthanlime it's also an attempt to fiddle with parser combinators. And initially I just cared about write-like syscalls synce I use strace to dump some binary data for fuzzing samples. Rabbit hole gets deeper :D
And yes, I don't care much about multithreading much at this point, since I do not RIIR strace at the moment and just started digging things.
They mistook random strings with code XD
gotta put that german street in there 🤣
great joke!
lime: ES-trace
everybody: STrace
me: STraik xD
It's actually pronounced gee-if
Anyone else eager to see a blazing memory profiler?
I have good news for you
Hey, great video, just wanted to share Yama is the god of the death in Hinduism.
It absolutely is, and that 2-second segment is a joke I was barely able to stay straight for!
I will never not feel stupid saying kibibytes. I know it's technically correct and an important distinction but for me, 1 kilobyte will always be 1024 bytes.
I ate the penguin, guys. Hope you don't mind
bro whats your secret to typing and thinking so damn fast. you're almost superhuman
That's the magic of editing for you! This video is HEAVILY scripted/produced. "Let's build a htop-like" is almost live, but some silent played at 2x. In that case the secret is a loot of prep work.
@@fasterthanlime tbh that's really smooth editing, can't even make out any jumpcuts or weird anomalies! Kudos good sir!
I watched so far...
the section about security was a bit of a false dilemma, maybe it might be surprising if you have never heard of ptrace before?
Yes, and I'm assuming that the audience for this video hasn't heard of ptrace before (otherwise you won't learn much).
A lot of folks were surprised re my "Getting food at SNES video games" video that Windows lets you inject DLLs into other processes, so I thought covering the threat model aspect would be a good idea.
Plus, if it was that trivial, why would Debian have tried switching to the more restrictive setting then had to roll it back? Clearly that's worth spending a couple minutes on :)
Whoa, as a German, it never occurred to me, you could pronounce strace as 'Strasse', but yeah...
im starting to think this guy likes rust
Well now the goal is to upskill myself to understand this.
Your mic looks like an png
You want to play games little fly?
I seem to be the only one, but the music feels a bit too loud to my ears. It sounds like it's competing with your voice, which isn't ideal. Great video otherwise!