Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

clang14 build with -update-debug-sections rewrite debug info core #307

Closed
zpget opened this issue Oct 12, 2022 · 14 comments
Closed

clang14 build with -update-debug-sections rewrite debug info core #307

zpget opened this issue Oct 12, 2022 · 14 comments

Comments

@zpget
Copy link

zpget commented Oct 12, 2022

compiler: clang14, default dwarf5
error msg:
BOLT-INFO: SCTC: patched 39 tail calls (36 forward) tail calls (3 backward) from a total of 39 while removing 0 double jumps and removing 28 basic blocks totalling 140 bytes of code. CTCs total execution count is 70740640 and the number of times CTCs are taken is 0.
BOLT-INFO: padding code to 0xb800000 to accommodate hot text
BOLT-WARNING: empty location list detected at 0x27 for DIE at 0x490b in CU at 0x53d
BOLT-WARNING: unexpected low_pc form value. Cannot update DIE at offset 0x491f
BOLT-WARNING: Unsupported DWARFLocationEntry Kind:5
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it):
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-bolt -enable-bat=1 test -o test.bolt -data test.fdata -align-macro-fusion=all -reorder-blocks=cache+ -reorder-functions=hfsort+ -split-functions=3 -split-all-cold -split-eh -dyno-stats -icf=1 -update-debug-sections

@aaupov
Copy link
Contributor

aaupov commented Oct 12, 2022

Hi @zpget,

Thanks for reporting! Can you please also include full backtrace and the version of BOLT used?
It would also be helpful for us to be able to repro the build - if clang14 binary is built manually, what's the CMake command line? If it's distro built, which package is it?

@ayermolo - does that look familiar? Can that be the cause of the crash?

BOLT-WARNING: Unsupported DWARFLocationEntry Kind:5

@zpget
Copy link
Author

zpget commented Oct 13, 2022

Hi @zpget,

Thanks for reporting! Can you please also include full backtrace and the version of BOLT used? It would also be helpful for us to be able to repro the build - if clang14 binary is built manually, what's the CMake command line? If it's distro built, which package is it?

@ayermolo - does that look familiar? Can that be the cause of the crash?

BOLT-WARNING: Unsupported DWARFLocationEntry Kind:5

  1. bolt version: llvm-project-llvmorg-14.0.0 release
  2. core line:
    bolt/lib/Rewrite/DWARFRewriter.cpp
    switch (Entry.Kind) {
    default:
    llvm_unreachable("Unsupported DWARFLocationEntry Kind.");

Kind:5

  1. binary code is complex , main module depend on many other modules(static link)

@aaupov
Copy link
Contributor

aaupov commented Oct 13, 2022

I would suggest you check if the issue reproduces with the trunk version of BOLT first. AFAIK DWARF5 support was added to BOLT after LLVM14 release and it wasn't backported.

@ayermolo
Copy link
Contributor

ayermolo commented Oct 13, 2022

Hi
I am currently on PTO so won't be able to look until next week, but does sound like you are using BOLT version that doesn't support DWARF5. Please try with trunk as Amir suggested.

@zpget
Copy link
Author

zpget commented Oct 13, 2022

BOLT version:
BOLT-INFO: BOLT version: 56ff67c
with latest trunk, still has core
switch (Entry.Kind) {
default:
errs() << "BOLT-WARNING: Unsupported DWARFLocationEntry Kind. type="
<< std::to_string(Entry.Kind) << '\n';
llvm_unreachable("Unsupported DWARFLocationEntry Kind.");
i add log
errs() << "BOLT-WARNING: Unsupported DWARFLocationEntry Kind. type="
<< std::to_string(Entry.Kind) << '\n';
and coredump before get:
BOLT-WARNING: Unsupported DWARFLocationEntry Kind. type=5

before coredump print so many warnings:
BOLT-WARNING: empty location list detected at 0x6dd5 for DIE at 0x1779b0 in CU at 0x215b0
BOLT-WARNING: unexpected low_pc form value. Cannot update DIE at offset 0x1779c2
BOLT-WARNING: empty location list detected at 0x6dd7 for DIE at 0x1779d2 in CU at 0x215b0
BOLT-WARNING: unexpected low_pc form value. Cannot update DIE at offset 0x1779db
BOLT-WARNING: unexpected low_pc form value. Cannot update DIE at offset 0x1779ff
BOLT-WARNING: unexpected low_pc form value. Cannot update DIE at offset 0x177a23

@zpget
Copy link
Author

zpget commented Oct 13, 2022

clang build with -gdwarf-4 -gstrict-dwarf ,
BOLT-WARNING: Unsupported DWARFLocationEntry Kind. type=8
add
@@ -516,6 +518,12 @@ void DWARFRewriter::updateUnitDebugInfo(
BaseAddress + Entry.Value0, BaseAddress + Entry.Value1,
Entry.Loc});
break;

  •            case dwarf::DW_LLE_start_length:
    
  •                 InputLL.emplace_back(DebugLocationEntry{
    
  •                  Entry.Value0, Entry.Value0 + Entry.Value1,
    
  •                  Entry.Loc});
    
  •              break;
    

can success ,
but has warning
BOLT-WARNING: empty location list detected at 0x6dd8 for DIE at 0x177aa4 in CU at 0x215b0
and
gdb load bin has no debug info warning
GNU gdb (GDB) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
https://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test.bolt...
DW_FORM_strp pointing outside of .debug_str section [in module /home/work/test.bolt]
(No debugging symbols found in test.bolt)

so something wrong with debuginfo update?

@aaupov
Copy link
Contributor

aaupov commented Oct 13, 2022

BOLT version: BOLT-INFO: BOLT version: 56ff67c with latest trunk, still has core

You're using non-upstreamed BOLT version which was last updated in Jan this year.
BOLT has been part of LLVM monorepo since then: https://github.com/llvm/llvm-project/tree/main/bolt

Please follow the instructions on that page (https://github.com/llvm/llvm-project/tree/main/bolt#manual-build) to check out and build the latest trunk version.

@zpget
Copy link
Author

zpget commented Oct 14, 2022

ok, now can fix coredump ,but get some ERROR:
BOLT-ERROR: unsupported form for DW_AT_call_return_pc

@ayermolo
Copy link
Contributor

Hmm. Are you sure you are on latest llvm trunk? I am pretty sure I fixed that and committed it.

@zpget
Copy link
Author

zpget commented Oct 14, 2022

with this commit: 4f158995b9cddae392bfb5989af8c83101ae0789
llvm/llvm-project@4f15899

today i see have a latest commit? 4d3a0cade2ed0bdc87256c197215691c2e279ed0
i need try again?

@ayermolo
Copy link
Contributor

I added support in https://reviews.llvm.org/D128526
Maybe I missed a case. Can you provide a binary and/or how it was build?

@zpget
Copy link
Author

zpget commented Oct 17, 2022

compiler: llvm-project-14.0.5.src/clang f68d4e64a17b5699e0245b1a7c445830d38fd75f
demo: simple main demo
#include
#include <stdio.h>
#include
#include <unistd.h>
int LOOPS=1000;
void test() {
for (int i = 0; i < LOOPS; i++ ) {
std::string tmp = "hello" + std::to_string(i);
std::cout << tmp << std::endl;
}
}

int main() {
while (true) {
test();
sleep(5);
}
return 0;
}
compile cmd: clang-14/bin/clang++ main.cpp -std=c++11 -Wl,-q
demo bin:
a.out.zip
errmsg:
BOLT-INFO: padding code to 0xa00000 to accommodate hot text
BOLT-ERROR: unsupported form for DW_AT_call_return_pc Function:__libc_csu_init
for DIE.dump()
0x00000696: DW_TAG_call_site
DW_AT_call_return_pc (0x00000000004016dc)

@ayermolo
Copy link
Contributor

Debug Info in question comes from GCC compiled code.
https://reviews.llvm.org/D136204

@zpget
Copy link
Author

zpget commented Oct 21, 2022

Debug Info in question comes from GCC compiled code. https://reviews.llvm.org/D136204

ok, test can work, thanks~

sid8123 pushed a commit to sid8123/llvm-project that referenced this issue Oct 25, 2022
GCC 12 produces DW_FORM_addr for DW_AT_call_return_pc. Added support for that.
Fixes facebookarchive/BOLT#307

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D136204
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants