delphix / sdb

The Slick Debugger
Apache License 2.0
57 stars 20 forks source link

crash when casting "zero-length" array right after member command #129

Open sdimitro opened 4 years ago

sdimitro commented 4 years ago
sdb> zfs_dbgmsg | head 1 | deref | member zdm_msg | cast char *
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/command.py", line 277, in _call
    yield drgn.cast(self.type, obj)
ValueError: cannot take address of value
----------------------------------------------------------
Link: https://github.com/delphix/sdb/issues/new
ahrens commented 3 years ago

Similar issues using zero-length arrays (rm_row is a zero-length array, declared as raidz_row_t *rm_row[0];

sdb> echo 0xffff929d5cd71d40 | cast zio_t * | member io_vsd | cast raidz_map_t* | member rm_row
sdb encountered an internal error due to a bug. Here's the
information you need to file the bug:
----------------------------------------------------------
Target Info:
    ProgramFlags.IS_LINUX_KERNEL
    Platform(<Architecture.X86_64: 1>, <PlatformFlags.IS_LITTLE_ENDIAN|IS_64_BIT: 3>)

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sdb/internal/repl.py", line 107, in eval_cmd
    for obj in invoke(self.target, [], input_):
  File "/usr/lib/python3/dist-packages/sdb/pipeline.py", line 147, in invoke
    yield from execute_pipeline(first_input, pipeline)
  File "/usr/lib/python3/dist-packages/sdb/pipeline.py", line 84, in execute_pipeline
    yield from massage_input_and_call(pipeline[-1], this_input)
  File "/usr/lib/python3/dist-packages/sdb/pipeline.py", line 43, in massage_input_and_call
    yield from cmd.call(objs)
  File "/usr/lib/python3/dist-packages/sdb/command.py", line 329, in call
    result, not issubclass(self.__class__, SingleInputCommand))
  File "/usr/lib/python3/dist-packages/sdb/command.py", line 292, in __invalid_memory_objects_check
    obj.read_()
TypeError: cannot read object with incomplete array type
sdb> echo 0xffff929d5cd71d40 | cast zio_t * | member io_vsd | cast raidz_map_t* | member rm_row[0]
sdb encountered an internal error due to a bug. Here's the
information you need to file the bug:
----------------------------------------------------------
Target Info:
    ProgramFlags.IS_LINUX_KERNEL
    Platform(<Architecture.X86_64: 1>, <PlatformFlags.IS_LITTLE_ENDIAN|IS_64_BIT: 3>)

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sdb/internal/repl.py", line 107, in eval_cmd
    for obj in invoke(self.target, [], input_):
  File "/usr/lib/python3/dist-packages/sdb/pipeline.py", line 147, in invoke
    yield from execute_pipeline(first_input, pipeline)
  File "/usr/lib/python3/dist-packages/sdb/pipeline.py", line 84, in execute_pipeline
    yield from massage_input_and_call(pipeline[-1], this_input)
  File "/usr/lib/python3/dist-packages/sdb/pipeline.py", line 43, in massage_input_and_call
    yield from cmd.call(objs)
  File "/usr/lib/python3/dist-packages/sdb/command.py", line 329, in call
    result, not issubclass(self.__class__, SingleInputCommand))
  File "/usr/lib/python3/dist-packages/sdb/command.py", line 290, in __invalid_memory_objects_check
    for obj in objs:
  File "/usr/lib/python3/dist-packages/sdb/command.py", line 375, in _call
    yield from result
  File "/usr/lib/python3/dist-packages/sdb/commands/member.py", line 311, in _call_one
    yield self._eval_member_terms(obj, terms)
  File "/usr/lib/python3/dist-packages/sdb/commands/member.py", line 293, in _eval_member_terms
    self._validate_array_index(obj.type_, idx)
  File "/usr/lib/python3/dist-packages/sdb/commands/member.py", line 276, in _validate_array_index
    if type_.length <= idx:
TypeError: '<=' not supported between instances of 'NoneType' and 'int'

It would be nice if member zero_length_array[N] worked (perhaps with a warning), and also if you could use array N to iterate over the entries in the array, given the number of entries.