[lldb-dev] Pending breakpoints to dlsym()ed functions

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Feb 15 08:20:16 PST 2018



> On Feb 15, 2018, at 3:56 AM, Dmitry Antipov via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> On 02/15/2018 02:21 PM, Pavel Labath wrote:
> 
>> I've tried your sample, and I was indeed able to reproduce the
>> problem. What makes your case special is that "sin" and "cos" are
>> indirect functions (STT_GNU_IFUNC), so we have to do some extra work
>> (call the resolver function) to resolve them. 
> 
> I've changed my sample to dlsym() a regular function instead of an indirect
> stub, and got a breakpoint hit, but:
> 
> (lldb) attach 16196
> Process 16196 stopped
> * thread #1, name = 'main', stop reason = signal SIGSTOP
>    frame #0: 0x0000000000400798 main`main(argc=1, argv=0x00007ffd6f662668) at main.c:16
>   13  	  for (a = 0; a < DELAY + argc; a++)
>   14  	    for (b = 0; b < DELAY + argc; b++)
>   15  	      for (c = 0; c < DELAY + argc; c++)
> -> 16  	        z += a + b + c;
>   17  	  while (1)
>   18  	    {
>   19  	      void *handle = dlopen ("libfoo.so", RTLD_LAZY);
> 
> Executable module set to "/home/dantipov/tmp/t-dl2/main".
> Architecture set to: x86_64--linux.
> (lldb) breakpoint set -n foo
> Breakpoint 1: no locations (pending).
> WARNING:  Unable to resolve breakpoint to any actual locations.
> (lldb) process continue
> Process 16196 resuming
> 1 location added to breakpoint 1
> (lldb) error: ld-linux-x86-64.so.2 0x0005d207: adding range [0x14eea-0x14f5a) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this error message
> error: ld-linux-x86-64.so.2 0x0005d207: adding range [0x14f70-0x14f76) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this error message
> error: ld-linux-x86-64.so.2 0x0005d268: adding range [0x14eea-0x14f5a) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this error message
> error: ld-linux-x86-64.so.2 0x0005d268: adding range [0x14f70-0x14f76) which has a base that is less than the function's low PC 0x15730. Please file a bug and attach the file at the start of this error message
> Process 16196 stopped
> * thread #1, name = 'main', stop reason = breakpoint 1.1
>    frame #0: 0x00007f3b1a8536f7 libfoo.so`foo(v=0.00000000000003907985046680551) at libfoo.c:6
>   3   	double
>   4   	foo (double v)
>   5   	{
> -> 6   	  return sin (v) + cos (v);
>   7   	}
> 
> This seems to be an another bug, isn't it?
> 

Yes, the compiler or linker is producing bad DWARF. It is creating DWARF that has a function that has a top level address range of something like [0x1000-0x2000) and it has a child lexical block with a range like [0x900-0x910). All address ranges must be contained in their parent ranges within a DW_TAG_subprogram in the DWARF. If you have llvm-dwarfdump, you can run "llvm-dwarfdump --verify" to see a list of the errors in the DWARF that you can use to file a compiler bug. Try running "llvm-dwarfdump --verify" on the .o file before it is linked. If there are DWARF problems with the .o file, then file a bug on the compiler. If the problem only exists on the final executable, then file a bug against your linker.

Greg

> Dmitry
> 
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and may contain
> confidential information.  Any unauthorized review, use, disclosure or distribution
> is prohibited.  If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> <libfoo.c><main.c><Makefile.txt>_______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list