Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(cli): mcap cat Sigsev on schemaless encoding #847

Closed
jon-chuang opened this issue Mar 13, 2023 · 2 comments · Fixed by #857
Closed

bug(cli): mcap cat Sigsev on schemaless encoding #847

jon-chuang opened this issue Mar 13, 2023 · 2 comments · Fixed by #857
Assignees
Labels
bug Something isn't working

Comments

@jon-chuang
Copy link
Contributor

jon-chuang commented Mar 13, 2023

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 jon-chuang added the bug Something isn't working label Mar 13, 2023
@foxhubber
Copy link

foxhubber bot commented Mar 13, 2023

Linear: FG-2431

@jon-chuang jon-chuang changed the title bug(cli): Sigsev on schemaless encoding bug(cli): mcap cat Sigsev on schemaless encoding Mar 13, 2023
@jon-chuang
Copy link
Contributor Author

jon-chuang commented Mar 13, 2023

Seems that the schema is a null pointer.

We should handle it as such.

james-rms added a commit that referenced this issue Mar 19, 2023
Previously, we did not handle schema being a nullptr

Fixes: #847

Co-authored-by: jon-chuang <jon-chuang@users.noreply.github.com>
Co-authored-by: james-rms <james.r.m.smith@gmail.com>
jtbandes added a commit that referenced this issue Jul 7, 2023
### Public-Facing Changes

CLI commands `filter`, `compress`, `decompress`, and `recover` no longer fail on schemaless channels (schema id = 0).

### Description

Don't fail when encountering schema ID 0.

Fixes FG-4182

See also:
- #829
- #847
- #579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

1 participant