Version 18.0.0: Heap use after free error when executing update section method on aarch64 architecture executable file

Hello everyone!

Thank you for your time! I am an intern at a chip company, and I suspect that I might have encountered a potential bug in a specific version of LLVM (18.0.0)

Whenever I execute the update section method of llvm-objcopy (which replaces the contents of a specific section) on an aarch64 architecture .o file under an environment with address sanitizer, I encounter a ‘heap use after free’ error. It seems that the memory allocation, deallocation, and subsequent access are all concentrated within the llvm::objcopy::executeObjcopyOnBinary function.

This issue occurs both when calling the update section-related API in the code and when using the command line to perform the update section in the terminal. Therefore, I suspect the problem might exist within the LLVM source code.

I checked the LLVM version I am using, which is 18.0.0. However, I noticed that the official source no longer provides the code for version 18.0.0. Could it be that the code for version 18.0.0 has been discontinued due to instability?" Should I consider switching from LLVM version 18.0.0 to a newer version for my development environment?


I am only allowed to include one image in the problem description. Here is another screenshot of the error log

Are you able to provide a command line and input files that reproduce the behaviour?

(please be mindful of any confidentiality requirements you may have, do not make any code public that you shouldn’t)

Please open a Github issue and attach the reproducer to it.

There was something wrong with 18.0, but I do not remember what it was, unlikely to be this though.

If this bug does not reproduce on the current main branch then sure, try a new build. Note that there are no 19.x releases though, so you’ll need to build it yourself.

You may find something in AddressSanitizer — Clang 19.0.0git documentation that can ignore this specific problem and allow you to continue using the current version.

And including output in reports is great, but text is much easier to deal with so prefer that form (assuming Discourse isn’t limiting you there too of course).