Re: [PATCH] gdb: fix for assigning NULL to std::string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Kazu
Thank you for the comment.
On Mon, Aug 22, 2022 at 2:41 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab@xxxxxxx> wrote:
On 2022/08/11 19:02, Lianbo Jiang wrote:
> When the lack of debuginfo package, try to load its module with the "mod
> -s xxx" in crash, it will cause the crash utility coredump as below:
>
>    crash> mod -s kpatch_test kpatch_test.ko
>    ...
>    terminate called after throwing an instance of 'std::logic_error'
>      what():  basic_string::_M_construct null not valid
>    Aborted (core dumped)

What does "the lack of debuginfo package" mean?  I tried to reproduce

Here, the kpatch is built as separate packages, and the debug information is
shipped into the debuginfo package.

When trying to reproduce it, do not install its debuginfo on your system.

I guess that you may try to strip the debuginfo from the test.ko, maybe it can be
also reproduced. 
 
this with my test module, but could not.  How can I reproduce this?

crash> mod -s test test.ko
      MODULE       NAME                         BASE           SIZE  OBJECT FILE
ffffffffc07c8040  test                   ffffffffc07c6000    16384  test.ko


And the gdb-10.2.patch already has a patch for gdb-10.2/gdb/symfile.c,
it would be better to restore the file before re-patching.

  tar xvzmf gdb-10.2.tar.gz \
+       gdb-10.2/gdb/symfile.c \
         gdb-10.2/gdb/Makefile.in

Yes, that would be fine.
 
Thanks.
Lianbo


Thanks,
Kazu

>
> Let's return the std::string() instead of std::string(NULL) when a
> string is null, because the check_specified_kernel_debug_file() may
> return NULL.
>
> Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx>
> ---
> (gdb) bt
> #0  __pthread_kill_implementation (threadid=<optimized out>, signo=<optimized out>, no_tid=<optimized out>) at pthread_kill.c:44
> #1  0x00007fff8b48223c in __GI_raise (sig=<optimized out>) at ../sysdeps/posix/raise.c:26
> #2  0x00007fff8b45c70c in __GI_abort () at abort.c:79
> #3  0x00007fff8b8cbee8 in __gnu_cxx::__verbose_terminate_handler () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
> #4  0x00007fff8b8c74e4 in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
> #5  0x00007fff8b8c75b0 in std::terminate () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:58
> #6  0x00007fff8b8c7a94 in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7fff8bac48b0 <typeinfo for std::logic_error>, dest=0x7fff8b8e93d0 <std::logic_error::~logic_error()>) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:95
> #7  0x00007fff8b889370 in std::__throw_logic_error (__s=0x1312445d0 "basic_string::_M_construct null not valid") at ../../../../../libstdc++-v3/src/c++11/functexcept.cc:70
> #8  0x000000013105d448 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag) [clone .constprop.0] (this=0x7fffdde41128, __beg=<optimized out>, __end=<optimized out>) at /usr/include/c++/11/bits/basic_string.tcc:212
> #9  0x0000000130da805c in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<std::allocator<char> > (__a=..., __s=<optimized out>, this=0x7fffdde41128) at /usr/include/c++/11/bits/basic_string.h:539
> #10 find_separate_debug_file_by_debuglink[abi:cxx11](objfile*) (objfile=<optimized out>) at symfile.c:1613
> #11 0x0000000130b41028 in elf_symfile_read (objfile=0x1003ccd5bb0, symfile_flags=...) at elfread.c:1304
> #12 0x0000000130da68b8 in read_symbols (objfile=<optimized out>, objfile@entry=0x1003ccd5bb0, add_flags=..., add_flags@entry=...) at symfile.c:800
> #13 0x0000000130da5f48 in syms_from_objfile_1 (add_flags=..., addrs=0x7fffdde41450, objfile=0x1003ccd5bb0) at symfile.c:997
> #14 syms_from_objfile (add_flags=..., addrs=0x7fffdde41450, objfile=0x1003ccd5bb0) at symfile.c:1014
> #15 symbol_file_add_with_addrs (abfd=<optimized out>, name=name@entry=0x1003db636a0 "kpatch_test.ko", add_flags=add_flags@entry=..., addrs=addrs@entry=0x7fffdde41450, flags=..., flags@entry=..., parent=parent@entry=0x0) at symfile.c:1123
> #16 0x0000000130da86e8 in symbol_file_add_from_bfd (parent=0x0, flags=..., addrs=0x7fffdde41450, add_flags=..., name=0x1003db636a0 "kpatch_test.ko", abfd=<optimized out>) at symfile.c:1204
> #17 symbol_file_add (name=0x1003db636a0 "kpatch_test.ko", add_flags=..., addrs=0x7fffdde41450, flags=...) at symfile.c:1217
> #18 0x0000000130dade4c in add_symbol_file_command (args=<optimized out>, from_tty=<optimized out>) at symfile.c:2388
> #19 0x0000000130a3e04c in do_const_cfunc (c=<optimized out>, args=<optimized out>, from_tty=<optimized out>) at cli/cli-decode.c:95
> #20 0x0000000130a40c48 in cmd_func (cmd=<optimized out>, args=<optimized out>, from_tty=<optimized out>) at cli/cli-decode.c:2181
> #21 0x0000000130e2344c in execute_command (p=<optimized out>, from_tty=<optimized out>) at top.c:668
> #22 0x0000000130dc9d9c in gdb_add_symbol_file (req=0x7fffdde41b10) at symtab.c:7436
> #23 gdb_command_funnel_1 (req=req@entry=0x7fffdde41b10) at symtab.c:7004
> #24 0x0000000130dcaa40 in gdb_command_funnel (req=0x7fffdde41b10) at symtab.c:6954
> #25 0x00000001308c78ec in gdb_interface (req=0x7fffdde41b10) at ../../gdb_interface.c:409
> #26 0x0000000130942adc in add_symbol_file (lm=0x1003ff62098) at ../../symbols.c:11914
> #27 0x00000001309442a0 in load_module_symbols (modref=<optimized out>, namelist=0x13146b682 <program_context+258> "kpatch_test.ko", base_addr=13837309855101681664) at ../../symbols.c:11852
> #28 0x000000013089f7b0 in do_module_cmd (flag=3, modref=<optimized out>, address=<optimized out>, objfile=<optimized out>, tree=<optimized out>) at ../../kernel.c:4602
> #29 0x000000013089da6c in cmd_mod () at ../../kernel.c:4204
> #30 0x00000001307e27bc in exec_command () at ../../main.c:892
> #31 0x000000013094d004 in exec_input_file () at ../../cmdline.c:1489
> #32 0x00000001307e2214 in is_input_file () at ../../main.c:988
> #33 exec_command () at ../../main.c:899
> #34 0x00000001307e2bbc in main_loop () at ../../main.c:839
> #35 0x0000000130c30654 in captured_main (data="" out>) at main.c:1284
> #36 gdb_main (args=<optimized out>) at main.c:1313
> #37 0x00000001308c5fbc in gdb_main_entry (argv=0x7fffdde45ca8, argc=2) at main.c:1338
> #38 gdb_main_loop (argc=2, argv=0x7fffdde45ca8) at ../../gdb_interface.c:81
> #39 0x00000001307d1158 in main (argc=<optimized out>, argv=0x7fffdde45ca8) at ../../main.c:720
> (gdb)
>
>   gdb-10.2.patch | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/gdb-10.2.patch b/gdb-10.2.patch
> index 577f5e45fc5a..3e0569d8ea98 100644
> --- a/gdb-10.2.patch
> +++ b/gdb-10.2.patch
> @@ -1650,3 +1650,13 @@ exit 0
>   
>         c_print_type_1 (type->field (i).type (),
>                         TYPE_FIELD_NAME (type, i),
> +--- gdb-10.2/gdb/symfile.c.orig
> ++++ gdb-10.2/gdb/symfile.c
> +@@ -1610,7 +1610,7 @@ find_separate_debug_file_by_debuglink (struct objfile *objfile)
> +   if (debugfile.empty ()) {
> +        char *name_copy;
> +        name_copy = check_specified_kernel_debug_file();
> +-       return std::string (name_copy);
> ++       return name_copy ? std::string (name_copy) : std::string ();
> +   }
> + #endif

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux