LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17944 - test_step_out_of_malloc_into_function_b_with_dwarf (TestThreadAPI.ThreadAPITestCase) fails with FreeBSD malloc
Summary: test_step_out_of_malloc_into_function_b_with_dwarf (TestThreadAPI.ThreadAPITe...
Status: RESOLVED FIXED
Alias: None
Product: lldb
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC FreeBSD
: P normal
Assignee: emaste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-15 08:54 PST by emaste
Modified: 2014-03-07 13:02 PST (History)
0 users

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emaste 2013-11-15 08:54:13 PST
Reproducing manually:

(lldb) b malloc
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) run
Process 64844 launched: '../tools/lldb/test/python_api/thread/a.out' (x86_64)
1 location added to breakpoint 1
Process 64844 stopped
* thread #1: tid = 100740, 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397, stop reason = breakpoint 1.1
    frame #0: 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397
   5394 malloc_init(void)
   5395 {
   5396
-> 5397         if (malloc_initialized == false)
   5398                 return (malloc_init_hard());
   5399
   5400         return (false);
(lldb) c
Process 64844 resuming
Process 64844 stopped
* thread #1: tid = 100740, 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397, stop reason = breakpoint 1.1
    frame #0: 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397
   5394 malloc_init(void)
   5395 {
   5396
-> 5397         if (malloc_initialized == false)
   5398                 return (malloc_init_hard());
   5399
   5400         return (false);
(lldb) c
Process 64844 resuming
ptr=0x801807400
a(1) returns 4
Process 64844 stopped
* thread #1: tid = 100740, 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397, stop reason = breakpoint 1.1
    frame #0: 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397
   5394 malloc_init(void)
   5395 {
   5396
-> 5397         if (malloc_initialized == false)
   5398                 return (malloc_init_hard());
   5399
   5400         return (false);
(lldb) c
Process 64844 resuming
ptr=0x801807800
b(2) returns 5
a(3) returns 6
Process 64844 exited with status = 0 (0x00000000) 

NB: this test has an @expectedFailureLinux # llvm.org/pr14416 tag
That PR is for watchpoints failing on i386 Linux, so perhaps a typo.
Comment 1 emaste 2013-11-15 09:05:10 PST
Our breakpoint ends up at the inlined malloc_init, so we have an extra frame in bt:

(lldb) breakpoint list
Current breakpoints:
1: name = 'malloc', locations = 1, resolved = 1, hit count = 1
  1.1: where = libc.so.7`malloc + 9 [inlined] malloc_init at malloc.c:5949, address = 0x0000000800dda809, resolved, hit count = 1 

(lldb) bt
* thread #1: tid = 101976, 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397, stop reason = breakpoint 1.1
  * frame #0: 0x0000000800dda809 libc.so.7`malloc [inlined] malloc_init at malloc.c:5397
    frame #1: 0x0000000800dda809 libc.so.7`malloc(size=1024) + 9 at malloc.c:5949
    frame #2: 0x00000000008006e5 a.out`b(val=1) + 37 at main2.cpp:29
    frame #3: 0x0000000000800680 a.out`a(val=1) + 32 at main2.cpp:19
    frame #4: 0x0000000000800772 a.out`main(argc=1, argv=0x00007fffffffd510) + 34 at main2.cpp:44
    frame #5: 0x00000000008005d1 a.out`_start(ap=<unavailable>, cleanup=<unavailable>) + 161 at crt1.c:97

malloc.c
  5388  /*                                                                      
  5389   * FreeBSD's pthreads implementation calls malloc(3), so the malloc     
  5390   * implementation has to take pains to avoid infinite recursion during  
  5391   * initialization.                                                      
  5392   */                                                                     
  5393  static inline bool                                                      
  5394  malloc_init(void)                                                       
  5395  {                                                                       
  5396                                                                          
  5397          if (malloc_initialized == false)                                
  5398                  return (malloc_init_hard());                            
  5399                                                                          
  5400          return (false);                                                 
  5401  }                                                                       

  5944  void *                                                                  
  5945  malloc(size_t size)                                                     
  5946  {                                                                       
  5947          void *ret;                                                      
  5948                                                                          
  5949          if (malloc_init()) {                                            
  5950                  ret = NULL;                                             
  5951                  goto OOM;                                               
  5952          }
Comment 2 emaste 2014-03-07 13:02:43 PST
Fixed in:

Sending        test/python_api/thread/TestThreadAPI.py
Transmitting file data .
Committed revision 203268.