Skip to content

rg_git_revparse leaves potentially multi-gig git files mapped in memory #246

@FlufflesTheDog

Description

@FlufflesTheDog

After a call to rg_git_revparse, it is possible to end up with exceptionally large files still mapped in memory for the remainder of the program's lifetime.
Discovered after downloading a SS13 repo (using --depth=10000) and having it consistently run out of memory during init, checking pmap, and finding a 2gb git file
Reproduced via the following code:

/world/New()
    var/rust_g = "./librust_g.so"
    world.log << call_ext(rust_g, "get_version")()
    world.log << call_ext(rust_g, "rg_git_revparse")("HEAD")

Output:

4.2.0
7f6f68c1fd5c68ff042f913511d35c799db3dfe6

(Also verified on 3.9.0, and 4.0.0)

I am unsure of the specifics behind which file is loaded and when it may or may not happen. Trying with a fresh repository, committing a large file, and running the code, does not cause the problem- but running git gc beforehand does produce the problem.

Example `pmap` output, with a ~500MB .pack file:
0000000008048000     12K r---- DreamDaemon
000000000804b000     40K r-x-- DreamDaemon
0000000008055000     16K r---- DreamDaemon
0000000008059000      4K r---- DreamDaemon
000000000805a000      4K rw--- DreamDaemon
00000000084fe000    444K rw---   [ anon ]
00000000d691e000      8K r---- libnss_resolve.so.2
00000000d6920000    140K r-x-- libnss_resolve.so.2
00000000d6943000     44K r---- libnss_resolve.so.2
00000000d694e000      8K r---- libnss_resolve.so.2
00000000d6950000      4K rw--- libnss_resolve.so.2
00000000d6951000     12K r---- libnss_mymachines.so.2
00000000d6954000    260K r-x-- libnss_mymachines.so.2
00000000d6995000     80K r---- libnss_mymachines.so.2
00000000d69a9000      8K r---- libnss_mymachines.so.2
00000000d69ab000      4K rw--- libnss_mymachines.so.2
00000000d69eb000 502908K r---- pack-306d105a058e29049fb5170d581298fcbf0f3e54.pack
00000000f550a000   2596K r---- librust_g.so
00000000f5793000   6628K r-x-- librust_g.so
00000000f5e0c000    352K r---- librust_g.so
00000000f5e64000    648K rw--- librust_g.so
...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions