Skip to content

Fix debug symbols #40873

Merged
novikd merged 6 commits intoClickHouse:masterfrom
azat:build/fix-debug-symbols-quirk
Sep 7, 2022
Merged

Fix debug symbols #40873
novikd merged 6 commits intoClickHouse:masterfrom
azat:build/fix-debug-symbols-quirk

Conversation

@azat
Copy link
Copy Markdown
Member

@azat azat commented Aug 31, 2022

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fix debug symbols

Patchset

Debug symbols had been broken in many places and should not work for a long time, the fix includes the following patches:

  • Fix debug symbols (Add a quirk to force clang emit .debug_aranges with ThinLTO)
    Also note, that to support it without a quirk, patch for llvm is required, the discussion can be found here and the patch here
  • Fix loading external symbols (previously it does not look at /usr/lib/debug/usr/bin/clickhouse.debug)
  • Do not compress debug symbols since dwarf parser cannot handle it, this increases the debug file from 510MB to 1.8GB, but deb packages compressed anyway, but the size of the deb also slightly increased from 834M to 962M
  • Do not try to load empty debug files (this is required due to build creates empty files for sanitizers and debug builds)
  • And also it disables the 02161_addressToLineWithInlines test, since they do not work always for now (will take a look at this)

Fixes: #36797
Fixes: #31639

@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-build Pull request with build/testing/packaging improvement label Aug 31, 2022
@azat azat changed the title Fix debug symbols (Add a quirk to force clang emit .debug_aranges with ThinLTO) RFC: Fix debug symbols (Add a quirk to force clang emit .debug_aranges with ThinLTO) Aug 31, 2022
@azat azat marked this pull request as draft August 31, 2022 20:47
@azat
Copy link
Copy Markdown
Member Author

azat commented Aug 31, 2022

Everything works as expected, and just for the info:

binary without LTO

azat@s2:.../tmp/debug-symbols$ objdump -j .debug_aranges -h clickhouse-binary 

clickhouse-binary:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn                 
 35 .debug_aranges 005e92e0  0000000000000000  0000000000000000  622f814e  2**0                
                  CONTENTS, READONLY, DEBUGGING, OCTETS  

binary with LTO

azat@s4:~/ch/tmp/40873$ objdump -j .debug_aranges -h clickhouse

clickhouse:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
 34 .debug_aranges 0055eb30  0000000000000000  0000000000000000  4b52c259  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS

So size more or less the same.

@azat azat changed the title RFC: Fix debug symbols (Add a quirk to force clang emit .debug_aranges with ThinLTO) RFC: Fix debug symbols Sep 2, 2022
azat added 4 commits September 2, 2022 23:22
…h ThinLTO)

Wrap a linker into a script that will add some settings (`-mllvm
-generate-arange-section`) in case of ThinLTO to emit `.debug_aranges`
symbols.

Dicussion in the LLVM can be found here [1].

  [1]: https://discourse.llvm.org/t/clang-does-not-produce-full-debug-aranges-section-with-thinlto/64898

Signed-off-by: Azat Khuzhin <[email protected]>
Signed-off-by: Azat Khuzhin <[email protected]>
…uch)

Although this increase debug symbol size from 510MB to 1.8GB, but it is
not a problem for packages, since they are compressed anyway.
Checked deb package, and size slightly increased though, 834M -> 962M.

Signed-off-by: Azat Khuzhin <[email protected]>
@azat azat force-pushed the build/fix-debug-symbols-quirk branch from 45fd2bc to 2fd8098 Compare September 2, 2022 21:22
azat added 2 commits September 2, 2022 23:23
This will avoid CANNOT_PARSE_ELF error for builds that has empty debug
file in clickhouse-common-static-dbg package, i.e. debug build.

Signed-off-by: Azat Khuzhin <[email protected]>
addressToLineWithInlines() may lead to the following error:

    Code: 465. DB::Exception: Received from localhost:9000. DB::Exception: could not find abbreviation code: while executing 'FUNCTION addressToLineWithInlines(arrayJoin(trace) :: 1) -> addressToLineWithInlines(arrayJoin(trace)) Array(String) : 0'. (CANNOT_PARSE_DWARF)

CI: https://s3.amazonaws.com/clickhouse-test-reports/40873/45fd2bcb218ace3231a026eb91d688f0093c6407/stateless_tests__release_.html
Signed-off-by: Azat Khuzhin <[email protected]>
@azat azat force-pushed the build/fix-debug-symbols-quirk branch from 2fd8098 to c6cbd98 Compare September 2, 2022 21:23
@azat azat marked this pull request as ready for review September 3, 2022 07:21
@azat
Copy link
Copy Markdown
Member Author

azat commented Sep 3, 2022

Now it works (and it was broken in lots of places, for details see pull request description), but inlines does not, I did not managed to fix it quickly so for now 02161_addressToLineWithInlines had been disabled and in the meantime I will take a look.

Test failures does not looks related and I will take a look in details a little bit later.

@novikd novikd self-assigned this Sep 4, 2022
Copy link
Copy Markdown
Member

@novikd novikd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, LGTM, but I think it might be useful to create issues for inlines and --compress-debug-sections because it's easy to forget that we are missing it.

@azat
Copy link
Copy Markdown
Member Author

azat commented Sep 4, 2022

I think it might be useful to create issues for inlines and --compress-debug-sections because it's easy to forget that we are missing it.

Actually I was going to take a look at the llvm parser (folly does not support it still), and I guess it will support them automatically.

However I'm not sure that this worth it, because symbolizing stacktraces takes lots of time here (and hence have a cache), and increasing it even more does not looks good to me, anyway deb packages are compressed (so debug file will be compressed anyway), and regular binaries compressed with zstd now.

But robust DWARF parser is still required, and maybe decompression will not take that much...

I will create needable issues today (need to take a brief look at some stuff).

@azat azat changed the title RFC: Fix debug symbols Fix debug symbols Sep 5, 2022
@azat azat mentioned this pull request Sep 5, 2022
@azat
Copy link
Copy Markdown
Member Author

azat commented Sep 5, 2022

Ok, #41000, #35405 and maybe #40772 should be enough to improve the situation

@azat
Copy link
Copy Markdown
Member Author

azat commented Sep 7, 2022

I would prefer to merge this before switching to clang/llvm-15 #41046 (it may help with the 00974_query_profiler failures there and also maybe clang-15 will make something different and this will stop working again).

@azat azat mentioned this pull request Sep 7, 2022
7 tasks
@novikd
Copy link
Copy Markdown
Member

novikd commented Sep 7, 2022

Stress test (msan) — Killed by signal (in clickhouse-server.log)

Must be fixed in #41050

Stateless tests (release, s3 storage) — fail: 1, passed: 4364, skipped: 61
Stateless tests (ubsan) — Tests are not finished, fail: 1, passed: 90, skipped: 3

Seems unrelated

@novikd novikd merged commit 499e479 into ClickHouse:master Sep 7, 2022
@azat azat deleted the build/fix-debug-symbols-quirk branch September 7, 2022 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-build Pull request with build/testing/packaging improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

introspection functions don't load debug symbols from clickhouse-common-static-dbg anymore addressToLine misbehaves in master

3 participants