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 15824 - LLDB thread states aren't properly maintained
Summary: LLDB thread states aren't properly maintained
Status: NEW
Alias: None
Product: lldb
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: All All
: P normal
Assignee: LLDB commit list
URL:
Keywords:
: 28455 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-22 19:49 PDT by Andy Kaylor
Modified: 2020-11-04 10:03 PST (History)
3 users (show)

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 Andy Kaylor 2013-04-22 19:49:50 PDT
The state of Thread objects is not properly maintained on Linux.  Even when debugging single-threaded inferiors, the thread state does not always properly reflect the actual state of the thread.
Comment 1 Andy Kaylor 2013-04-23 16:36:20 PDT
Having written a test for this, I see that the test fails on Darwin platforms as well.
Comment 2 emaste 2013-09-08 12:56:13 PDT
With my FreeBSD thread WIP I see the same failure in test_state_after_breakpoint_with_dwarf.

What is odd is that I don't even see SBThread::IsStopped() getting called.

I enabled logging to run the test:
export LLDB_LOG="lldb_unit_test.log"                                            
export LLDB_LOG_OPTION="api step process thread event expr state"               

and in the log I see:
SBDebugger(0x80159b600)::GetSelectedTarget () => SBTarget(0x80b696100): a.out   
SBTarget(0x80b696100)::GetProcess () => SBProcess(0x801736000)                  
SBProcess(0x801736000)::GetNumThreads () => 1                                   
SBProcess(0x801736000)::GetThreadAtIndex (index=0) => SBThread(0x80b701e00)     
SBTarget(0x80b696100)::GetProcess () => SBProcess(0x801736000)                  
SBProcess(0x801736000)::GetTarget () => SBTarget(0x80b696100)                   
SBTarget(0x80b696100)::GetExecutable () => SBFileSpec(0x80b6abb20)              
SBFileSpec(0x80b6abb20)::GetPath (dst_path="/tank/emaste/src/llvm/tools/lldb/test/functionalities/thread/state/a.out", dst_len=1024) => 72
SBProcess(0x801736000)::GetState () => stopped                                  
SBProcess(0x801736000)::GetNumThreads () => 1                                   

I can confirm that the GetThreadAtIndex (index=0) call corresponds to the python test code "thread = process.GetThreadAtIndex(0)"

So I think it may actually be that the SWIG / python interface has some issue rather than the thread's state actually being incorrect.
Comment 3 labath 2015-10-07 04:00:52 PDT
*** Bug 25081 has been marked as a duplicate of this bug. ***
Comment 4 emaste 2015-12-22 11:41:44 PST
Another test failing in the same way on FreeBSD now:

======================================================================
FAIL: test_state_after_continue_dwarf (TestThreadStates.ThreadStateTestCase)
   Test thread state after continue.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 2263, in dwarf_test_method
    return attrvalue(self)
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 608, in wrapper
    func(*args, **kwargs)
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbtest.py", line 608, in wrapper
    func(*args, **kwargs)
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py", line 34, in test_state_after_continue
    self.thread_state_after_continue_test()
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py", line 141, in thread_state_after_continue_test
    self.wait_for_running_event()
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py", line 106, in wait_for_running_event
    lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning])
  File "/tank/emaste/src/llvm/tools/lldb/packages/Python/lldbsuite/test/lldbutil.py", line 750, in expect_state_changes
    test.assertEqual(expected_state, got_state)
AssertionError: 6 != 4
Config=x86_64-/usr/bin/clang
----------------------------------------------------------------------
Ran 5 tests in 6.281s

RESULT: FAILED (0 passes, 1 failures, 0 errors, 0 skipped, 4 expected failures, 0 unexpected successes)

[TestThreadStates.py FAILED]
Comment 5 labath 2016-07-07 10:31:12 PDT
*** Bug 28455 has been marked as a duplicate of this bug. ***
Comment 6 emaste 2020-11-04 10:03:55 PST
reported fixed on FreeBSD in  https://reviews.llvm.org/D90757