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

[FreeBSD 14] Build breaks on arm64: ld: error: undefined symbol: brk #1499

Closed
yurivict opened this issue Apr 3, 2024 · 3 comments
Closed

Comments

@yurivict
Copy link

yurivict commented Apr 3, 2024

ld: error: undefined symbol: brk

referenced by mmap_hook.cc
              src/low_level_alloc_unittest-mmap_hook.o:(sbrk)
did you mean: sbrk
defined in: src/low_level_alloc_unittest-mmap_hook.o

brk isn't supposed to be used in general.

Version: 2.15
FreeBSD 14.0

@alk
Copy link
Contributor

alk commented Apr 3, 2024

Thanks for bug report. So looking closer, looks like our mmap hooks simply assumes that FreeBSD can do sbrk and looks like perhaps 14.0 doesn't anymore. I.e. without even looking at config.h where we have indication of sbrk availability. I welcome patch to fix this.

As for more general matter of not using sbrk. So, yes, in principle we should consider. But in practical terms, just doing our current version of mmap allocator will actually break large heap fragmentation unittest. Yes, this test's specific case is quite subtle, but it is one way to show that sbrk's built-in feature of allocating memory sequentially does give us substantial benefit. There is also potential for another benefit (and potential security downside) which is that brk area being immediately after bss makes certain TLB-miss effects cheaper. I.e. heap sitting closer (likely same pmd) to .bss/.data has possibly measurable performance benefit by having shorter page table walks.

So, yes, I will accept patches and benchmarks towards doing mmap-only allocation, but we cannot simply amputate sbrk just yet.

@alk alk changed the title Build breaks on arm64: ld: error: undefined symbol: brk [FreeBSD 14] Build breaks on arm64: ld: error: undefined symbol: brk Apr 3, 2024
@yurivict
Copy link
Author

yurivict commented Apr 3, 2024

It looks like brk was just accidentally removed on ARM platforms on FreeBSD.
I don't advocate removal of the sbrk method.
I just noticed that this port fails to build on arm64, and am trying to see what needs to be done to make it build again.

alk added a commit that referenced this issue Apr 3, 2024
Apparently some recent FreeBSDs occasionally lack brk. So our code
which previously hard-coded that this OS has brk (which we use to
implement hooked sbrk) fails to compile.

Our configure scripts already detects sbrk, so we simply need to pay
attention. Fixes github issue #1499
@alk alk closed this as completed Apr 3, 2024
@zxombie
Copy link

zxombie commented Jun 7, 2024

sbrk and brk have intentionally never been in a release of FreeBSD on arm64 since first released in 11.0 in 2016.

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

No branches or pull requests

3 participants