sdb icon indicating copy to clipboard operation
sdb copied to clipboard

Non-consistent behavior and occasional crash when going out of bounds with `member`

Open sdimitro opened this issue 5 years ago • 1 comments

When going out of bounds on an array with member we expect that the user knows what they are doing so we just print a warning and do as we are told:

sdb> addr spa_namespace_avl | member avl_root->avl_child[3]
warning: member: index out of bounds for array of type 'struct avl_node *[2]' (requested index: 3)
*(struct avl_node *)0xffff90cbda7ff4a0 = {
	.avl_child = (struct avl_node *[2]){ 0x100000000, 0xffff90cbc396ce00 },
	.avl_pcb = (uintptr_t)0,
}

Turns out though this is not always the case:

sdb> zfs_dbgmsg | head 1 | deref | member zdm_msg[2]
warning: member: index out of bounds for array of type 'char [1]' (requested index: 2)
sdb encountered an internal error due to a bug. Here's the
information you need to file the bug:
----------------------------------------------------------
Target Info:
	ProgramFlags.IS_LIVE|IS_LINUX_KERNEL
	Platform(<Architecture.X86_64: 1>, <PlatformFlags.IS_LITTLE_ENDIAN|IS_64_BIT: 3>)

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/internal/repl.py", line 85, in eval_cmd
    for obj in invoke(self.target, [], input_):
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/pipeline.py", line 165, in invoke
    yield from execute_pipeline(first_input, pipeline)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/pipeline.py", line 83, in execute_pipeline
    yield from massage_input_and_call(pipeline[-1], this_input)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/pipeline.py", line 43, in massage_input_and_call
    yield from cmd.call(objs)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/command.py", line 235, in call
    yield from result
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/commands/member.py", line 326, in _call
    obj, terms)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/commands/member.py", line 307, in _eval_member_terms
    obj = obj[idx]
_drgn.FaultError: out of bounds of value
----------------------------------------------------------
Link: https://github.com/delphix/sdb/issues/new

sdimitro avatar Jan 14 '20 18:01 sdimitro

Looking more into the specifics - the first example works because avl_root is not really dereferenced. Dereferencing it on demand causes the same error as the second example:

sdb> addr spa_namespace_avl | member avl_root | deref | member avl_child[3]
warning: member: index out of bounds for array of type 'struct avl_node *[2]' (requested index: 3)
sdb encountered an internal error due to a bug. Here's the
information you need to file the bug:
----------------------------------------------------------
Target Info:
	ProgramFlags.IS_LIVE|IS_LINUX_KERNEL
	Platform(<Architecture.X86_64: 1>, <PlatformFlags.IS_LITTLE_ENDIAN|IS_64_BIT: 3>)

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/internal/repl.py", line 85, in eval_cmd
    for obj in invoke(self.target, [], input_):
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/pipeline.py", line 165, in invoke
    yield from execute_pipeline(first_input, pipeline)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/pipeline.py", line 83, in execute_pipeline
    yield from massage_input_and_call(pipeline[-1], this_input)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/pipeline.py", line 43, in massage_input_and_call
    yield from cmd.call(objs)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/command.py", line 235, in call
    yield from result
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/commands/member.py", line 337, in _call
    obj, terms)
  File "/usr/local/lib/python3.6/dist-packages/sdb-0.1.0-py3.6.egg/sdb/commands/member.py", line 308, in _eval_member_terms
    obj = obj[idx]
_drgn.FaultError: out of bounds of value
----------------------------------------------------------
Link: https://github.com/delphix/sdb/issues/new

sdimitro avatar Jan 14 '20 20:01 sdimitro