From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B2E883858412; Tue, 26 Dec 2023 13:37:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2E883858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1703597878; bh=GCglJdwnk3Q0xa49AZoI6lZvikbprO7tI5cKQ3VZiXo=; h=From:To:Subject:Date:From; b=nWUoRWEmexMpS09FR0DkZnYF6GERHL/ktndYETPzT1qSvcCb5znyDhtSGgRbTsMtB LBY9tTLCD4TToWncnlLxKXPY8hHoDXu1TbLCXILWWDdbTJHLY0aEj9MXFUAQoHqJQ+ SwdGouOLMnIGNQAZt0yELHVhA1VFF2Mpme1gohXg= From: "hopelee1994 at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug gdb/31192] New: GDB hang with CPU 100% when printing a variable with reference type Date: Tue, 26 Dec 2023 13:37:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: 14.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hopelee1994 at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31192 Bug ID: 31192 Summary: GDB hang with CPU 100% when printing a variable with reference type Product: gdb Version: 14.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: hopelee1994 at gmail dot com Target Milestone: --- When debugging MySQL 8.0.13 and set a breakpoint at function `JOIN::optimiz= e` with gdb-14.1, the gdb will hang with 100% CPU if I print a variable named `all_fields` which is the type `List &` in that point. If you want to reproduce that, every simple query statement on MySQL 8.0.13 will hit this breakpoint. If I pstack the gdb, the stack is like this: Thread 1 (Thread 0x7fe594ab4c40 (LWP 90562) "gdb"): #0 0x00007fe594b44d9c in malloc () from /lib64/libc.so.6 #1 0x0000000000b3223d in operator new (sz=3Dsz@entry=3D128) at ../../gdbsupport/new-op.cc:59 #2 0x0000000000700072 in __gnu_cxx::new_allocator::allocate (this=3D, __n=3D) at /opt/rh/devtoolset-7/root/usr/include/c++/7/ext/new_allocator.h:111 #3 std::allocator_traits >::allocate (__a=3D..= ., __n=3D) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/alloc_traits.h:436 #4 std::_Vector_base >::_M_alloca= te (this=3D, __n=3D) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_vector.h:172 #5 std::vector >::_M_realloc_insert<>(__gnu_cxx::__normal_iterator > >) (this=3Dthis@entry=3D0x7ffe6913ad98, __position=3D..., __position@entry=3D.= ..) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/vector.tcc:406 #6 0x00000000006f7196 in std::vector >::emplace_back<>() (this=3D0x38) at /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/vector.tcc:105 #7 dwarf2_add_member_fn (cu=3D0x25e81d730, type=3D, die=3D0x2a30fd110, fip=3D0x0) at ../../gdb/dwarf2/read.c:12203 #8 handle_struct_member_die (child_die=3Dchild_die@entry=3D0x25e81d8d0, type=3D, fi=3Dfi@entry=3D0x7ffe6913ad60, template_args=3Dtemplate_args@entry=3D0x7ffe6913ace0, cu=3Dcu@entry=3D0x64f= c2860) at ../../gdb/dwarf2/read.c:12949 #9 0x00000000006f2541 in process_structure_scope (cu=3D0x64fc2860, die=3D0x25e81ced0) at ../../gdb/dwarf2/read.c:12999 #10 process_die (die=3Ddie@entry=3D0x25e81ced0, cu=3Dcu@entry=3D0x64fc2860)= at ../../gdb/dwarf2/read.c:6687 #11 0x00000000006f1c67 in read_namespace (cu=3D0x25e81ced0, die=3D0x29ae932= 70) at ../../gdb/dwarf2/read.c:14158 #12 process_die (die=3Ddie@entry=3D0x29ae93270, cu=3Dcu@entry=3D0x64fc2860)= at ../../gdb/dwarf2/read.c:6727 #13 0x00000000006f45da in read_file_scope (die=3Ddie@entry=3D0x2a0524c70, cu=3Dcu@entry=3D0x64fc2860) at ../../gdb/dwarf2/read.c:7686 #14 0x00000000006f26f3 in process_die (die=3D0x2a0524c70, cu=3Dcu@entry=3D0= x64fc2860) at ../../gdb/dwarf2/read.c:6658 #15 0x00000000006f7928 in process_full_comp_unit (pretend_language=3D, cu=3D0x64fc2860) at ../../gdb/dwarf2/read.c:6422 #16 process_queue (per_objfile=3D0x10fefb0) at ../../gdb/dwarf2/read.c:5696 #17 dw2_do_instantiate_symtab (skip_partial=3D, per_objfile=3D0x10fefb0, per_cu=3D0x703d9b0) at ../../gdb/dwarf2/read.c:1770 #18 dw2_instantiate_symtab (per_cu=3D0x703d9b0, per_objfile=3D0x10fefb0, skip_partial=3Dskip_partial@entry=3Dfalse) at ../../gdb/dwarf2/read.c:1792 #19 0x00000000006f811c in dw2_expand_symtabs_matching_one(dwarf2_per_cu_dat= a*, dwarf2_per_objfile*, gdb::function_view, gdb::function_view) (per_cu=3D, per_objfile=3D, file_matcher=3D..., expansion_notify=3D...) = at ../../gdb/dwarf2/read.c:3042 #20 0x00000000006f8a19 in cooked_index_functions::expand_symtabs_matching(objfile*, gdb::function_view, lookup_name_info const*, gdb::function_view, gdb::function_view, enum_flags, domain_enum, search_domain) (this=3D, objfile=3D, file_matcher=3D..., lookup_name=3D, symbol_matcher=3D..., expansion_notify=3D..., search_flags=3D..., domain=3DVAR_DOMAIN, kind=3DALL= _DOMAIN) at ../../gdb/dwarf2/read.c:16954 #21 0x000000000095bcde in objfile::lookup_symbol (this=3Dthis@entry=3D0x129= 4910, kind=3D, kind@entry=3DGLOBAL_BLOCK, name=3Dname@entry=3D0x65= 3f490 "List", domain=3D, domain@entry=3DVAR_DOMAIN) at ../../gdb/symfile-debug.c:285 #22 0x000000000096d754 in lookup_symbol_via_quick_fns (domain=3DVAR_DOMAIN, name=3D0x653f490 "List", block_index=3DGLOBAL_BLOCK, objfile=3D0x1294910) at ../../gdb/symtab.c:2411 #23 lookup_symbol_in_objfile (objfile=3D0x1294910, block_index=3DGLOBAL_BLO= CK, name=3D0x653f490 "List", domain=3DVAR_DOMAIN) at ../../gdb/symtab.c:2542 #24 0x000000000096d8ee in gdb::function_view::bind(lookup_global_or_static_symbol(char con= st*, block_enum, objfile*, domain_enum)::{lambda(objfile*)#1}&)::{lambda(gdb::fv_detail::erased_callab= le, objfile*)#1}::_FUN(gdb::fv_detail::erased_callable, objfile*) () at ../../gdb/symtab.c:2588 #25 0x000000000092b393 in gdb::function_view::operator()(objfile*) const (args#0=3D0x1294910, this=3D) at ../../gdb/../gdbsupport/function-view.h:289 #26 svr4_iterate_over_objfiles_in_search_order (gdbarch=3D, cb=3D..., current_objfile=3D) at ../../gdb/solib-svr4.c:3454 #27 0x000000000096ef75 in lookup_global_or_static_symbol (name=3Dname@entry=3D0x653f490 "List", block_index=3Dblock_index@entry=3DGL= OBAL_BLOCK, objfile=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN) at ../../gdb/symtab.c:25= 85 #28 0x000000000096ff16 in lookup_global_symbol (name=3Dname@entry=3D0x653f4= 90 "List", block=3Dblock@entry=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN) at ../../gdb/symtab.c:2641 #29 0x0000000000668856 in cp_lookup_bare_symbol (langdef=3Dlangdef@entry=3D= 0xb70cb0 , name=3Dname@entry=3D0x653f490 "List", block=3Dblock@= entry=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN, search=3D1) at ../../gdb/cp-namespace.c= :209 #30 0x0000000000668c62 in lookup_namespace_scope (langdef=3Dlangdef@entry=3D0xb70cb0 , name=3Dname@entry=3D0x653f490 "List", block=3Dblock@entry=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN, scope=3Dscope@entry=3D0x52c0a0 "", scope_len=3Dscope_len@entry=3D0) at ../../gdb/cp-namespace.c:751 #31 0x0000000000669b71 in cp_lookup_symbol_nonlocal (langdef=3D0xb70cb0 , name=3D0x653f490 "List", block=3D0x0, domain=3DVAR_D= OMAIN) at ../../gdb/cp-namespace.c:781 #32 0x00000000009767dd in lookup_symbol_aux (name=3D0x653f490 "List", match_type=3Dmatch_type@entry=3Dsymbol_name_match_type::FULL, block=3Dblock@entry=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN, language=3Dlanguage@entry=3Dlanguage_cplus, is_a_field_of_this=3Dis_a_field_of_this@entry=3D0x0) at ../../gdb/symtab.c:= 2150 #33 0x0000000000976966 in lookup_symbol_in_language (name=3D0x653f490 "List= ", block=3Dblock@entry=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN, lang=3Dlangu= age_cplus, is_a_field_of_this=3Dis_a_field_of_this@entry=3D0x0) at ../../gdb/symtab.c:= 1958 #34 0x00000000009769f2 in lookup_symbol (name=3D, block=3Dblock@entry=3D0x0, domain=3Ddomain@entry=3DVAR_DOMAIN, is_a_field_of_this=3Dis_a_field_of_this@entry=3D0x0) at ../../gdb/symtab.c:= 1970 #35 0x000000000066b70b in replace_typedefs (info=3Dinfo@entry=3D0x5a9af90, ret_comp=3D0x7a2ba60, finder=3Dfinder@entry=3D0x61c9d0 , data=3Ddata@entry=3D0xb683a0 ) at ../../gdb/cp-support.c:506 #36 0x000000000066b7aa in replace_typedefs (info=3Dinfo@entry=3D0x5a9af90, ret_comp=3D0x7a2bac0, finder=3Dfinder@entry=3D0x61c9d0 , data=3Ddata@entry=3D0xb683a0 ) at ../../gdb/cp-support.c:539 #37 0x000000000066b1d4 in cp_canonicalize_string_full (string=3Dstring@entry=3D0x4c98b70 "List", finder=3Dfinder@entry=3D0x= 61c9d0 , data=3Ddata@entry=3D0xb683a0 ) at ../../gdb/cp-support.c:595 #38 0x000000000061cedd in print_name_maybe_canonical (name=3D0x4c98b70 "List", flags=3Dflags@entry=3D0xb683a0 , stream=3Dstream@entry=3D0x127ac90) at ../../gdb/c-typeprint.c:90 #39 0x000000000061d8d0 in c_type_print_base_1 (type=3D, stream=3Dstream@entry=3D0x127ac90, show=3Dshow@entry=3D-1, level=3Dlevel@en= try=3D0, language=3Dlanguage@entry=3Dlanguage_cplus, flags=3Dflags@entry=3D0xb683a0 , podata=3D0x7ffe6913c2e4) at ../../gdb/c-typeprint.c:= 1641 #40 0x000000000061dff9 in c_type_print_base_1 (type=3Dtype@entry=3D0x5a9ad7= 0, stream=3Dstream@entry=3D0x127ac90, show=3Dshow@entry=3D-1, level=3Dlevel@en= try=3D0, language=3Dlanguage@entry=3Dlanguage_cplus, flags=3Dflags@entry=3D0xb683a0 , podata=3D0x7ffe6913c2e4) at ../../gdb/c-typeprint.c:= 1476 #41 0x000000000061d638 in c_print_type_1 (type=3Dtype@entry=3D0x5a9ad70, varstring=3Dvarstring@entry=3D0x52c0a0 "", stream=3Dstream@entry=3D0x127ac9= 0, sho #41 0x000000000061d638 in c_print_type_1 (type=3Dtype@entry=3D0x5a9ad70, varstring=3Dvarstring@entry=3D0x52c0a0 "", stream=3Dstream@entry=3D0x127ac9= 0, show=3Dshow@entry=3D-1, level=3Dlevel@entry=3D0, language=3Dlanguage@entry=3Dlanguage_cplus, flags=3D0xb683a0 , podata=3D0x7ffe6913c2e4) at ../../gdb/c-typeprint.c:129 #42 0x000000000061d827 in c_print_type (type=3D0x5a9ad70, varstring=3D0x52c= 0a0 "", stream=3D0x127ac90, show=3D-1, level=3D0, language=3Dlanguage_cplus, flags= =3D0xb683a0 ) at ../../gdb/c-typeprint.c:178 #43 0x00000000009e283b in type_print (type=3D, varstring=3D, stream=3D, show=3D) at ../../gdb/typeprint.c:391 #44 0x0000000000621208 in c_value_print (val=3D0x6915f10, stream=3D0x127ac9= 0, options=3D0x7ffe6913c440) at ../../gdb/c-valprint.c:545 #45 0x00000000009fe59d in value_print (val=3Dval@entry=3D0x56a63b0, stream=3D0x127ac90, options=3Doptions@entry=3D0x7ffe6913c440) at ../../gdb/valprint.c:1209 #46 0x0000000000862e8f in print_formatted (val=3Dval@entry=3D0x56a63b0, size=3Dsize@entry=3D0, options=3Doptions@entry=3D0x7ffe6913c440, stream=3D<= optimized out>) at ../../gdb/printcmd.c:337 #47 0x0000000000865b0a in print_value (val=3Dval@entry=3D0x56a63b0, opts=3D= ...) at ../../gdb/printcmd.c:1260 #48 0x0000000000865d8d in print_command_1 (args=3D, voidprint=3D) at ../../gdb/printcmd.c:1377 #49 0x000000000062fdd0 in cmd_func (cmd=3D, args=3D, from_tty=3D) at ../../gdb/cli/cli-decode.c:2735 #50 0x00000000009ad901 in execute_command (p=3D, p@entry=3D0= x48cb140 "p all_fields", from_tty=3Dfrom_tty@entry=3D1) at ../../gdb/top.c:575 #51 0x000000000063367a in cli_interp::exec (this=3D0x1205570, command_str=3D0x48cb140 "p all_fields") at ../../gdb/cli/cli-interp.c:242 #52 0x00000000007bfe7d in interp_exec (interp=3Dinterp@entry=3D0x1205570, command_str=3D) at ../../gdb/interps.c:265 #53 0x0000000000828d13 in mi_cmd_interpreter_exec (command=3D, argv=3D, argc=3D2) at ../../gdb/mi/mi-interp.c:189 #54 0x000000000082e25b in mi_cmd_execute (parse=3Dparse@entry=3D0x5a9b1c0) = at ../../gdb/mi/mi-main.c:2148 #55 0x000000000082edae in captured_mi_execute_command (context=3D0x5a9b1c0, uiout=3D0x1240a60, mi=3D0x12c2e40) at ../../gdb/mi/mi-main.c:1831 #56 mi_execute_command (cmd=3D, from_tty=3D) = at ../../gdb/mi/mi-main.c:1955 #57 0x00000000008275f2 in mi_execute_command_wrapper (cmd=3D= ) at ../../gdb/mi/mi-interp.c:222 #58 mi_execute_command_input_handler (cmd=3D...) at ../../gdb/mi/mi-interp.= c:244 #59 0x0000000000714642 in gdb_readline_no_editing_callback (client_data=3D) at ../../gdb/event-top.c:846 #60 0x00000000009e7410 in stdin_event_handler (error=3D, client_data=3D0x10b2a00) at ../../gdb/ui.c:155 #61 0x0000000000b2eebd in gdb_wait_for_event (block=3Dblock@entry=3D1) at ../../gdbsupport/event-loop.cc:694 #62 0x0000000000b2f634 in gdb_do_one_event (mstimeout=3Dmstimeout@entry=3D-= 1) at ../../gdbsupport/event-loop.cc:264 #63 0x00000000008056e7 in start_event_loop () at ../../gdb/main.c:407 #64 captured_command_loop () at ../../gdb/main.c:471 #65 0x00000000008073e5 in captured_main (data=3Ddata@entry=3D0x7ffe6913c960= ) at ../../gdb/main.c:1324 #66 gdb_main (args=3Dargs@entry=3D0x7ffe6913c980) at ../../gdb/main.c:1343 I have done some analysis on the stack, it seems that gdb keeps finding sym= bols like `List`, `LIST`, etc and do a loop in cooked_index_functions::expand_symtabs_matching, which causes it hanging wi= th 100% CPU. If I do a typecast to remove the reference before printing the variable like this: (gdb) p (List)all_fields gdb will return very quickly. And the above hang phenomenon does not appear in gdb 9.2 version. So I think this is a regression. --=20 You are receiving this mail because: You are on the CC list for the bug.=