Skip to content

rust-lldb: "ValueError: Positive integer expected" trying to print regex::Captures #52185

Closed
@alex

Description

@alex

I'm in a frame of Rust code with a regex::Captures local:

frame #9: 0x00000001000095d1 dom-rooting`dom_rooting::parse_callgraph_call::he390b4fd9cb48a86(line="D 1 2") at main.rs:84
   81  	    let m = RE.captures(line)
   82  	        .expect(&format!("parse failure: {:?}", line));
   83
-> 84  	    return (m[1].parse().unwrap(), m[2].parse().unwrap());
   85  	}
   86
   87  	fn parse_callgraph(p: &Path) -> Callgraph {

I try to print m (the regex::Captures) and hilarity ensues:

(lldb) p m
Traceback (most recent call last):
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 99, in print_val
    is_tuple_like = False)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 220, in print_struct_val
    body = separator.join([render_child(idx) for idx in range(field_start_index, len(fields))])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 213, in render_child
    return this + print_val(field_val.get_wrapped_value(), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 132, in print_val
    is_tuple_like = True)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 220, in print_struct_val
    body = separator.join([render_child(idx) for idx in range(field_start_index, len(fields))])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 213, in render_child
    return this + print_val(field_val.get_wrapped_value(), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 115, in print_val
    return print_std_vec_val(val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 264, in print_std_vec_val
    internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 299, in print_array_of_values
    return ', '.join([render_element(i) for i in range(length)])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 297, in render_element
    return print_val(element_val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 156, in print_val
    return print_val(lldb_val.GetChildAtIndex(discriminant_val), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 132, in print_val
    is_tuple_like = True)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 220, in print_struct_val
    body = separator.join([render_child(idx) for idx in range(field_start_index, len(fields))])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 213, in render_child
    return this + print_val(field_val.get_wrapped_value(), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 112, in print_val
    return print_str_slice_val(val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 268, in print_str_slice_val
    return read_utf8_string(data_ptr, length)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 305, in read_utf8_string
    data = process.ReadMemory(ptr_val.as_integer(), byte_count, error)
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 7184, in ReadMemory
    return _lldb.SBProcess_ReadMemory(self, *args)
ValueError: Positive integer expected
Traceback (most recent call last):
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 132, in print_val
    is_tuple_like = True)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 220, in print_struct_val
    body = separator.join([render_child(idx) for idx in range(field_start_index, len(fields))])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 213, in render_child
    return this + print_val(field_val.get_wrapped_value(), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 115, in print_val
    return print_std_vec_val(val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 264, in print_std_vec_val
    internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 299, in print_array_of_values
    return ', '.join([render_element(i) for i in range(length)])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 297, in render_element
    return print_val(element_val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 156, in print_val
    return print_val(lldb_val.GetChildAtIndex(discriminant_val), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 132, in print_val
    is_tuple_like = True)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 220, in print_struct_val
    body = separator.join([render_child(idx) for idx in range(field_start_index, len(fields))])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 213, in render_child
    return this + print_val(field_val.get_wrapped_value(), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 112, in print_val
    return print_str_slice_val(val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 268, in print_str_slice_val
    return read_utf8_string(data_ptr, length)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 305, in read_utf8_string
    data = process.ReadMemory(ptr_val.as_integer(), byte_count, error)
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 7184, in ReadMemory
    return _lldb.SBProcess_ReadMemory(self, *args)
ValueError: Positive integer expected
Traceback (most recent call last):
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 115, in print_val
    return print_std_vec_val(val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 264, in print_std_vec_val
    internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 299, in print_array_of_values
    return ', '.join([render_element(i) for i in range(length)])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 297, in render_element
    return print_val(element_val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 156, in print_val
    return print_val(lldb_val.GetChildAtIndex(discriminant_val), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 132, in print_val
    is_tuple_like = True)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 220, in print_struct_val
    body = separator.join([render_child(idx) for idx in range(field_start_index, len(fields))])
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 213, in render_child
    return this + print_val(field_val.get_wrapped_value(), internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 112, in print_val
    return print_str_slice_val(val, internal_dict)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 268, in print_str_slice_val
    return read_utf8_string(data_ptr, length)
  File "/Users/agaynor/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/etc/lldb_rust_formatters.py", line 305, in read_utf8_string
    data = process.ReadMemory(ptr_val.as_integer(), byte_count, error)
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 7184, in ReadMemory
    return _lldb.SBProcess_ReadMemory(self, *args)
ValueError: Positive integer expected
(regex::re_unicode::Captures) $3 = {
  text = "D 1 2"
  locs = {
    __0 = {
      buf = RawVec<core::option::Option<usize>, alloc::alloc::Global> {
ptr: Unique<core::option::Option<usize>> {
pointer: NonZero<*const core::option::Option<usize>>(&0x10288d280),
_marker: PhantomData<core::option::Option<usize>>
},
cap: 8,
a: Global
}
      len = 8
    }
  }
  named_groups = Arc<std::collections::hash::map::HashMap<alloc::string::String, usize, std::collections::hash::map::RandomState>> {
ptr: NonNull<alloc::arc::ArcInner<std::collections::hash::map::HashMap<alloc::string::String, usize, std::collections::hash::map::RandomState>>> {
pointer: NonZero<*const alloc::arc::ArcInner<std::collections::hash::map::HashMap<alloc::string::String, usize, std::collections::hash::map::RandomState>>>(&0x10288c500)
},
phantom: PhantomData<std::collections::hash::map::HashMap<alloc::string::String, usize, std::collections::hash::map::RandomState>>
}
}
(lldb)

System info:

~/p/h/dom-rooting ❯❯❯ rust-lldb --version
lldb-900.0.57
  Swift-4.0
~/p/h/dom-rooting ❯❯❯ rustc --version
rustc 1.27.0 (3eda71b00 2018-06-19)
~/p/h/dom-rooting ❯❯❯ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.5
BuildVersion:	17F77

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions