#2136 cannot build with sanitizer because of memory overcommit disabled
Closed: Fixed 2 years ago by praiskup. Opened 2 years ago by mtasaka.

For example, trying to compile jd with gcc, with adding "-fsanitizer=address -fsanitize=undefined" :
https://src.fedoraproject.org/rpms/jd/tree/nightly-2

now fails on copr: https://copr.fedorainfracloud.org/coprs/mtasaka/jd-nightly/build/3814463/
but suceeds on koji: https://koji.fedoraproject.org/koji/taskinfo?taskID=84594686

copr build shows:

Sanity check compiler command line: g++ -fsanitize=address -fsanitize=undefined sanitycheckcpp.cc -o sanitycheckcpp.exe -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_FILE_OFFSET_BITS=64 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/jd-0.7.0/.package_note-jd-0.7.0-2.D20220320git940e818.fc37.san.x86_64.ld -pthread
Sanity check compile stdout:

-----
Sanity check compile stderr:

-----
Running test binary command: /builddir/build/BUILD/jd-0.7.0/JDim/redhat-linux-build/meson-private/sanitycheckcpp.exe

results in:

==91==ERROR: AddressSanitizer failed to allocate 0xdfff0001000 (15392894357504) bytes at address 2008fff7000 (errno: 12)
==91==ReserveShadowMemoryRange failed while trying to map 0xdfff0001000 bytes. Perhaps you're using ulimit -v

So meson tries to create small binary (basically just containing int main() { return 0; } , and tries to execute it, but execution fails (autotools generated configure also does the same trial, also it fails similarly).
A binary compiled with sanitizer firstly tries to allocate shadow virtual memory, usually Tbytes (here virtual 14Tbytes), this is usually no problem with normal linux system.
https://github.com/google/sanitizers/wiki/AddressSanitizer#ulimit--v

However, on copr, build log shows:

+ cat /proc/sys/vm/overcommit_memory
2

So overcommit is disabled, so allocating virtual Tbytes fails. This means that sanitizer build cannot be done on copr (actually binary with sanitizer cannot be executed), which is very incovenient. On koji, the above value is 0, so overcommit can be done and binary with sanitizer can be executed.

Note that previously sanitizer build was no problem on copr, so overcommit setting changed recently?


Thank you for the report.

Note that previously sanitizer build was no problem on copr, so overcommit setting changed recently?

Yes. We experimented weird OOM errors so we tried all kind of things, including this.
It turned out to be a problem of multiple swap volumes (fixed separately) . So I believe
I can drop the overcommit_memory hack now.

Metadata Update from @praiskup:
- Issue tagged with: ansible

2 years ago

Metadata Update from @praiskup:
- Issue assigned to praiskup

2 years ago

Commit 73725efd relates to this ticket

Commit 6c6a61f1 relates to this ticket

Should be fixed. Thanks again.

Metadata Update from @praiskup:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Actually now build with sanitizer is now good on copr, thank you,

Log in to comment on this ticket.

Metadata