bug(cli): `mcap cat` Sigsev on schemaless encoding
jon-chuang opened this issue · 2 comments
jon-chuang commented
Description
The following error is encountered:
running /tmp/tmpbiz8i177
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xb77ca5]
goroutine 1 [running]:
github.com/foxglove/mcap/go/cli/mcap/cmd.printMessages({0xc00034fc40?, 0xc000355480?}, {0xf5fee0, 0xc000010018}, {0xf5cd80, 0xc00050c1c0}, 0x1)
/home/jonch/Desktop/Programming/systems/mcap/go/cli/mcap/cmd/cat.go:113 +0x4e5
github.com/foxglove/mcap/go/cli/mcap/cmd.glob..func5.1(0x75?, {0x7fe3f42e82f8?, 0xc000010af8})
/home/jonch/Desktop/Programming/systems/mcap/go/cli/mcap/cmd/cat.go:236 +0x1c5
github.com/foxglove/mcap/go/cli/mcap/utils.WithReader({0xf64f50, 0xc0000360d8}, {0x7ffe00805e75?, 0x0?}, 0xc0002dfd90)
/home/jonch/Desktop/Programming/systems/mcap/go/cli/mcap/utils/utils.go:104 +0x431
github.com/foxglove/mcap/go/cli/mcap/cmd.glob..func5(0x145c420?, {0xc00009b980, 0x1, 0x2?})
/home/jonch/Desktop/Programming/systems/mcap/go/cli/mcap/cmd/cat.go:226 +0x312
github.com/spf13/cobra.(*Command).execute(0x145c420, {0xc00009b960, 0x2, 0x2})
/home/jonch/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:876 +0x67b
github.com/spf13/cobra.(*Command).ExecuteC(0x145b520)
/home/jonch/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
/home/jonch/go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
github.com/foxglove/mcap/go/cli/mcap/cmd.Execute()
/home/jonch/Desktop/Programming/systems/mcap/go/cli/mcap/cmd/root.go:21 +0x25
main.main()
/home/jonch/Desktop/Programming/systems/mcap/go/cli/mcap/main.go:6 +0x17
CompletedProcess(args=['mcap', 'cat', '--json', '/tmp/tmpbiz8i177'], returncode=2, stdout=b'')
- Version: 1.0.2
- Platform: Ubuntu 22.04
Steps To Reproduce
In python/mcap/tests/test_writer.py
:
def test_generate_sample_data():
file = NamedTemporaryFile("w+b")
writer = Writer(file, compression=CompressionType.ZSTD)
writer.start(library="test")
channel_id = writer.register_channel(
schema_id=0,
topic="sample_topic",
message_encoding="json",
)
writer.add_message(
channel_id=channel_id,
log_time=0,
data=json.dumps({"sample": "test"}).encode(encoding="utf-8"),
publish_time=0,
)
writer.finish()
file.seek(0)
print("running", file.name)
result = subprocess.run(['mcap', 'cat', '--json', file.name], stdout=subprocess.PIPE)
print(result)
if __name__ == "__main__":
test_generate_sample_data()
Expected Behavior
No Sigsev. Note that running with a schema works.
See the comment for mcap.Writer.register_channel
:
A schema_id of 0 indicates there is no schema for this channel.
jon-chuang commented
Seems that the schema
is a null pointer.
We should handle it as such.