[SERVER-72979] Check whether 'globalServiceContext' is NULL before dereferencing it in the GDB python extension Created: 18/Jan/23  Updated: 27/Oct/23  Resolved: 18/Jan/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Mohammad Dashti (Inactive) Assignee: Mohammad Dashti (Inactive)
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Sprint: QE 2023-01-23
Participants:
Linked BF Score: 0

 Description   

In the GDB Python extension (in here),  the 'globalServiceContext' is dereferenced before checking whether it's NULL or not. This can cause a server crash if this variable is not initialized yet (e.g., BF-25267).



 Comments   
Comment by Mohammad Dashti (Inactive) [ 18/Jan/23 ]

Based on this Slack discussion with max.hirschhorn@mongodb.com, decided not to go forward with a fix, as adding more safety checks to the pretty printers is not a general direction that we want to go forward with.

Comment by Mohammad Dashti (Inactive) [ 18/Jan/23 ]

In addition, there's another bug that causes this error:

[2022/05/08 16:09:13.855] When the function is done executing, GDB will silently stop.' in javascript_stack
[2022/05/08 16:09:13.855] Traceback (most recent call last):
[2022/05/08 16:09:13.855]   File "buildscripts/gdb/mongo.py", line 783, in invoke
[2022/05/08 16:09:13.855]     self.javascript_stack()
[2022/05/08 16:09:13.855]   File "buildscripts/gdb/mongo.py", line 820, in javascript_stack
[2022/05/08 16:09:13.855]     gdb.selected_frame().older().select()
[2022/05/08 16:09:13.855] AttributeError: 'NoneType' object has no attribute 'select'
[2022/05/08 16:09:14.056] Error occurred in Python: 'NoneType' object has no attribute 'select'
 

Comment by Mohammad Dashti (Inactive) [ 18/Jan/23 ]

Here's the related stack-trace from BF-25267:

(anonymous namespace)::globalServiceContext'").dereference()
gdb.MemoryError: Cannot access memory at address 0x563109980690
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/hang_analyzer.py", line 136, in execute
    dumpers.dbg.dump_info(pinfo, take_dump=False)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/dumper.py", line 461, in dump_info
    call([dbg, "--quiet", "--nx"] + list(
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/process.py", line 39, in call
    raise Exception("Bad exit code %d from %s" % (ret, " ".join(args)))
[resmoke] 16:09:14.716Z Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/hang_analyzer.py", line 136, in execute
    dumpers.dbg.dump_info(pinfo, take_dump=False)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/dumper.py", line 461, in dump_info
    call([dbg, "--quiet", "--nx"] + list(
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/process.py", line 39, in call
    raise Exception("Bad exit code %d from %s" % (ret, " ".join(args)))
[2022-05-08 16:09:14,716 - resmoke - INFO] Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/hang_analyzer.py", line 136, in execute
    dumpers.dbg.dump_info(pinfo, take_dump=False)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/dumper.py", line 461, in dump_info
    call([dbg, "--quiet", "--nx"] + list(
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/process.py", line 39, in call
    raise Exception("Bad exit code %d from %s" % (ret, " ".join(args)))
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/run/__init__.py", line 302, in _execute_suite
    executor.run()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/executor.py", line 101, in run
    (report, interrupted) = self._run_tests(test_queue, setup_flag, teardown_flag,
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/executor.py", line 185, in _run_tests
    joined = test_queue.join(TestSuiteExecutor._TIMEOUT)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/utils/queue.py", line 43, in join
    self.all_tasks_done.wait(remaining)
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/threading.py", line 316, in wait
    gotit = waiter.acquire(True, timeout)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/sighandler.py", line 37, in _handle_sigusr1
    _dump_and_log(header_msg)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/sighandler.py", line 74, in _dump_and_log
    _analyze_pids(logger, pids_to_analyze)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/sighandler.py", line 162, in _analyze_pids
    _hang_analyzer.execute()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/hang_analyzer.py", line 175, in execute
    raise RuntimeError(
RuntimeError: Exceptions were thrown while dumping. There may still be some valid dumps.
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/run/__init__.py", line 302, in _execute_suite
    executor.run()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/executor.py", line 101, in run
    (report, interrupted) = self._run_tests(test_queue, setup_flag, teardown_flag,
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/executor.py", line 185, in _run_tests
    joined = test_queue.join(TestSuiteExecutor._TIMEOUT)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/utils/queue.py", line 43, in join
    self.all_tasks_done.wait(remaining)
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/threading.py", line 316, in wait
    gotit = waiter.acquire(True, timeout)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/sighandler.py", line 37, in _handle_sigusr1
    _dump_and_log(header_msg)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/sighandler.py", line 74, in _dump_and_log
    _analyze_pids(logger, pids_to_analyze)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/sighandler.py", line 162, in _analyze_pids
    _hang_analyzer.execute()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/hang_analyzer/hang_analyzer.py", line 175, in execute
    raise RuntimeError(
RuntimeError: Exceptions were thrown while dumping. There may still be some valid dumps.
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 209, in _run_single_copy
    test_case.run_test()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/interface.py", line 137, in run_test
    self._execute(proc)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/interface.py", line 158, in _execute
    raise self.failureException("%s failed" % (self.short_description()))
AssertionError: JSTest jstests/parallel/basicPlus.js failed
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/job.py", line 84, in __call__
    self._run(queue, interrupt_flag, teardown_flag, hook_failure_flag)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/job.py", line 130, in _run
    self._execute_test(test, hook_failure_flag)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/job.py", line 176, in _execute_test
    raise test.propagate_error
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/unittest/case.py", line 593, in run
    self._callTestMethod(testMethod)
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
    method()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 258, in run_test
    self._run_single_copy()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 213, in _run_single_copy
    self._raise_if_unsafe_exit(self.return_code)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 276, in _raise_if_unsafe_exit
    raise self.propagate_error  # pylint: disable=raising-bad-type
buildscripts.resmokelib.errors.UnsafeExitError: Mongo shell exited with code 1 while running jstest basicPlus.js. Further test execution may be unsafe.
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 209, in _run_single_copy
    test_case.run_test()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/interface.py", line 137, in run_test
    self._execute(proc)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/interface.py", line 158, in _execute
    raise self.failureException("%s failed" % (self.short_description()))
AssertionError: JSTest jstests/parallel/basicPlus.js failed
Traceback (most recent call last):
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/job.py", line 84, in __call__
    self._run(queue, interrupt_flag, teardown_flag, hook_failure_flag)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/job.py", line 130, in _run
    self._execute_test(test, hook_failure_flag)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/job.py", line 176, in _execute_test
    raise test.propagate_error
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/unittest/case.py", line 59, in testPartExecutor
    yield
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/unittest/case.py", line 593, in run
    self._callTestMethod(testMethod)
  File "/opt/mongodbtoolchain/revisions/c6da1cf7f0b4b60d53566305e59857d3d540dcf7/stow/python3-v3.fZa/lib/python3.9/unittest/case.py", line 550, in _callTestMethod
    method()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 258, in run_test
    self._run_single_copy()
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 213, in _run_single_copy
    self._raise_if_unsafe_exit(self.return_code)
  File "/data/mci/7fa1f617126817856e69372141d14836/src/buildscripts/resmokelib/testing/testcases/jstest.py", line 276, in _raise_if_unsafe_exit
    raise self.propagate_error  # pylint: disable=raising-bad-type
buildscripts.resmokelib.errors.UnsafeExitError: Mongo shell exited with code 1 while running jstest basicPlus.js. Further test execution may be unsafe.

Generated at Thu Feb 08 06:23:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.