Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rhel 8 install - panic: unable to mmap memory: cannot allocate memory #2820

Open
fabioasdias opened this issue May 10, 2024 · 8 comments
Open
Labels

Comments

@fabioasdias
Copy link

TruffleHog Version

Can't do it, --version doesn't run. From installer, 3.75.1

Trace Output

Can't run trace, all I got was:

panic: unable to mmap memory: cannot allocate memory

goroutine 1 [running]:
[github.com/tetratelabs/wazero/internal/wasm.NewMemoryInstance(0xc000a028f0)](http://github.com/tetratelabs/wazero/internal/wasm.NewMemoryInstance(0xc000a028f0))
        /home/runner/go/pkg/mod/[github.com/tetratelabs/wazero@v1.7.0/internal/wasm/memory.go:85](http://github.com/tetratelabs/wazero@v1.7.0/internal/wasm/memory.go:85) +0x1d7
[github.com/tetratelabs/wazero/internal/wasm.(*ModuleInstance).buildMemory(0xc0009a3100](http://github.com/tetratelabs/wazero/internal/wasm.(*ModuleInstance).buildMemory(0xc0009a3100), 0xc00103e540)
        /home/runner/go/pkg/mod/[github.com/tetratelabs/wazero@v1.7.0/internal/wasm/module.go:658](http://github.com/tetratelabs/wazero@v1.7.0/internal/wasm/module.go:658) +0x2d
[github.com/tetratelabs/wazero/internal/wasm.(*Store).instantiate(0xc00080a1e0](http://github.com/tetratelabs/wazero/internal/wasm.(*Store).instantiate(0xc00080a1e0), {0x3ac1be0, 0x587bc20}, 0xc00103e540, {0x2fc19ea, 0x3}, 0xc0001b5c80, {0x587bc20, 0x0, 0x0})
        /home/runner/go/pkg/mod/[github.com/tetratelabs/wazero@v1.7.0/internal/wasm/store.go:366](http://github.com/tetratelabs/wazero@v1.7.0/internal/wasm/store.go:366) +0x2c5
[github.com/tetratelabs/wazero/internal/wasm.(*Store).Instantiate(0xc00080a1e0](http://github.com/tetratelabs/wazero/internal/wasm.(*Store).Instantiate(0xc00080a1e0), {0x3ac1be0, 0x587bc20}, 0x0?, {0x2fc19ea?, 0x0?}, 0x0?, {0x587bc20, 0x0, 0x0})
        /home/runner/go/pkg/mod/[github.com/tetratelabs/wazero@v1.7.0/internal/wasm/store.go:325](http://github.com/tetratelabs/wazero@v1.7.0/internal/wasm/store.go:325) +0x5a
[github.com/tetratelabs/wazero.(*runtime).InstantiateModule(0xc0001cc480](http://github.com/tetratelabs/wazero.(*runtime).InstantiateModule(0xc0001cc480), {0x3ac1be0, 0x587bc20}, {0x3ad3950, 0xc0000b4dc0}, {0x3ae9760, 0xc0001705a0})
        /home/runner/go/pkg/mod/[github.com/tetratelabs/wazero@v1.7.0/runtime.go:312](http://github.com/tetratelabs/wazero@v1.7.0/runtime.go:312) +0x1e5
[github.com/tetratelabs/wazero.(*runtime).InstantiateWithConfig(0xc0001cc480](http://github.com/tetratelabs/wazero.(*runtime).InstantiateWithConfig(0xc0001cc480), {0x3ac1be0, 0x587bc20}, {0x54f9200?, 0xc000c1f260?, 0xc000effba0?}, {0x3ae9760, 0xc0001705a0})
        /home/runner/go/pkg/mod/[github.com/tetratelabs/wazero@v1.7.0/runtime.go:277](http://github.com/tetratelabs/wazero@v1.7.0/runtime.go:277) +0x74
[github.com/wasilibs/go-re2/internal.init.0()](http://github.com/wasilibs/go-re2/internal.init.0())
        /home/runner/go/pkg/mod/[github.com/wasilibs/go-re2@v1.5.2/internal/re2_wazero.go:170](http://github.com/wasilibs/go-re2@v1.5.2/internal/re2_wazero.go:170) +0x38d

Environment

  • OS: red hat
  • Version 8.8

Additional Context

Fresh OS install, ran the installer helper from the documentation (that downloads the install.sh | sh) and it refuses to start.

@rgmz
Copy link
Contributor

rgmz commented May 11, 2024

This seems to be related to wasilibs/go-re2#78.

@fabioasdias
Copy link
Author

ok, "adding more memory" is an easy enough problem to solve. Is there any guidance on sizing? That was run on a 4gb instance just for testing, bare system, does it really need that much memory out of the bat (not even --version works)

@dustin-decker
Copy link
Contributor

I would recommend starting with 16gb and evaluate your memory usage from there. It really depends on what you are scanning.

@anuraaga
Copy link

Hi @fabioasdias - on the 4GB machine, just wondering, are you able to build while forcing the version of go-re2 to the latest main version and see if the issue still happens? The issue stems from how much virtual memory is available to the application, most systems don't have an issue even with 4GB but if memory overcommit is disabled, then the virtual memory space can be limited. A fix for unix is included in main but I haven't been able to release it yet since I haven't been able to make a low virtual memory reproduction environment. If you're able to verify it, I think I can release it. Thanks and sorry for the trouble.

@fabioasdias
Copy link
Author

I did not build it, I used the curl | sh installation instructions which pull over the binaries, if I'm not mistaken. The laziest way I could possibly do it. There's nothing special to it, it's just a VM. I'd recon free virtualbox and an ubuntu base image might be the easiest way to make that happen, also lets one compile with more memory, then cut it off to test. I have near nil experience with go, and "forcing the version of go-re2" means nothing to me, so, sorry about that.

@anuraaga
Copy link

Got it @fabioasdias, yeah I thought that might be the case. I was able to set up a VM and verify the fix with vm.overcommit_memory=2 (I wonder if your system has vm.overcommit_memory=0, would you be able to check it with sysctl vm.overcommit_memory for good measure?) so have released a new patch. Once this project updates, hopefully it will resolve your issue and it will be great to confirm then. Thanks for the patience.

@fabioasdias
Copy link
Author

Running 3.76.3 worked with more memory. overcommit is set to 0 on this system.
Even with the new version, no joy using only 4gb of ram.

@anuraaga
Copy link

Thanks for confirming the overcommit setting @fabioasdias

It looks like that version probably barely missed getting the patch, it does seem to be in main now

https://github.com/trufflesecurity/trufflehog/blob/v3.76.3/go.mod#L82

So next release hoping the overcommit issue will be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants