{"id":13502898,"url":"https://github.com/fasterthanlime/mevi","last_synced_at":"2025-04-07T18:08:29.910Z","repository":{"id":145617905,"uuid":"610871722","full_name":"fasterthanlime/mevi","owner":"fasterthanlime","description":"A memory visualizer in Rust (ptrace + userfaultfd)","archived":false,"fork":false,"pushed_at":"2024-10-03T03:26:34.000Z","size":796,"stargazers_count":695,"open_issues_count":2,"forks_count":18,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-31T17:11:26.022Z","etag":null,"topics":["memory","memory-profiler","ptrace","ptrace-injection","userfaultfd"],"latest_commit_sha":null,"homepage":"https://youtu.be/DpnXaNkM9_M","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fasterthanlime.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["fasterthanlime"]}},"created_at":"2023-03-07T16:43:58.000Z","updated_at":"2025-03-23T01:40:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ccf511b-5ce7-4f39-88f8-472440c35bdb","html_url":"https://github.com/fasterthanlime/mevi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fmevi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fmevi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fmevi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fasterthanlime%2Fmevi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fasterthanlime","download_url":"https://codeload.github.com/fasterthanlime/mevi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247704568,"owners_count":20982298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["memory","memory-profiler","ptrace","ptrace-injection","userfaultfd"],"created_at":"2024-07-31T22:02:29.015Z","updated_at":"2025-04-07T18:08:29.885Z","avatar_url":"https://github.com/fasterthanlime.png","language":"Rust","readme":"\n# mevi\n\nA memory visualizer for Linux 5.7+\n\nMade for this video: https://www.youtube.com/watch?v=DpnXaNkM9_M\n\n## Prerequisite\n\nThe `vm.unprivileged_userfaultfd` sysctl needs to be switched to 1:\n\n```shell\n$ sudo sysctl -w vm.unprivileged_userfaultfd=1\n```\n\nDoing this effectively \"softens\" your system to some attacks, so only do this in\na VM or if you're reckless, but also, it seems less awful than running mevi +\ntracees as root. (No, giving the `mevi` binary CAP_PTRACE isn't enough).\n\nYou can _technically_ run a bunch of apps with only user faults, but some fairly\nbasic stuff like `cat /hosts` will fail with EFAULT without it, so, I'm not\nmaking it easy to go that route - if you _really_ know what you're doing you can\nfigure out where to pass the \"user faults only\" flag.\n\n## Usage\n\nInstall the `mevi` executable:\n\n```shell\n$ just install\n```\n\n(Or, without [just](https://github.com/casey/just), look into the `Justfile` for\nthe cargo invocation)\n\nTo build \u0026 serve the frontend, you'll need to install support for the wasm\ntarget via rustup:\n\n```shell\n$ rustup target add wasm32-unknown-unknown\n```\n\nAnd to have [trunk](https://trunkrs.dev/) installed.\n\n```shell\n$ just serve\n```\n\nOpen the frontend in your browser: \u003chttp://localhost:8080\u003e\n\nFrom another terminal, start the program you want to trace via mevi:\n\n```shell\n$ mevi PROGRAM ARGS\n```\n\nThe frontend should connect to `http://localhost:5001/stream`.\n\nIf you're running this on a remote server, you'll need to forward both ports, with SSH for example:\n\n```shell\nssh -L 5001:localhost:5001 -L 8080:localhost:8080 your-remote-host\n```\n\n## License\n\nThis project is primarily distributed under the terms of both the MIT license\nand the Apache License (Version 2.0).\n\nSee [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.\n\n## FAQ / Troubleshooting\n\n### I get `EPERM` at some point\n\nDid you skip past that `sysctl` note above?\n\n### The RSS numbers don't match up with htop/btop/procmaps etc.\n\nmevi only tracks private+anonymous memory mappings. The discrepancy probably\ncomes from mapped files, and to a lesser extent, shared memory.\n\n### I have a tiny program and everything goes by way too fast.\n\nTry sleeping in your loops! Computers go fast noawadays and mevi _tries_ not to\nslow your program down.\n\n### I have a multi-threaded program and it's all wrong\n\nYeah, sorry about that. userfaultfd events don't have all the info we need, and\nptrace observes events out-of-order, so the view of multi-threaded programs\ngets out-of-sync with the kernel.\n\n### Can I run this on a big program?\n\nSure, Firefox works, with a non-snap version, and with sandbox disabled, like\nso (THIS IS DANGEROUS, THE SANDBOX IS THERE FOR A REASON).\n\nFirst let's make sure you don't have firefox running in the background:\n\n```shell\n$ pkill firefox\n# you can do it several times, until `pidof firefox` returns nothing\n```\n\nThen:\n\n```shell\n$ RUST_LOG=error RUST_BACKTRACE=1 MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1 MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 mevi /usr/lib/firefox/firefox\n```\n\n### Does this show backtraces?\n\nNo, but you can do that in your fork.\n\n### Does this allow travelling back in time?\n\nNo, but you can do that in your fork.\n\n### Does this have yet another, secret third feature?\n\nClearly not, but again, you can do that in your fork. This is a research\nproject, I will not be maintaining it beyond \"have it run in its current form\".\n\nIf you want to spin this out into its own product, more power to you, but I'll\nhave already moved on.\n\n### Why isn't this published on crates.io?\n\nIt's not a library and it's not usable without the frontend anyway. One day\nstable cargo will let us build wasm artifacts and ship them with the resulting\nbinary, but that day is not today.\n\n### Why isn't this using eBPF?\n\nI wanted to see how far I could take ptrace + userfaultfd. I'm interested in\nexploring eBPF later.\n","funding_links":["https://github.com/sponsors/fasterthanlime"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffasterthanlime%2Fmevi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffasterthanlime%2Fmevi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffasterthanlime%2Fmevi/lists"}