Skip to content

br log truncate: SIGSEGV inside cleanUpFor() #63358

Closed

Description

@kennytm

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Perform br log truncate --until

2. What did you expect to see? (Required)

Truncate happens successfully.

3. What did you see instead (Required)

Panics with this stack trace:

We are going to truncate 3030 files, up to TS 2025-09-03 01:42:23.0000.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0х5848f74]

goroutine 3865 [running]:
github.com/pingcap/tidb/br/pkg/stream.MigrationExt.cleanUpFor({...}, 0x4002720fc0, 0x400084eed8)
    /.../release/tidb/br/pkg/stream/stream_netas.go:896 +0x584
github.com/pingcap/tidb/br/pkg/stream.MigrationExt.doTruncateLogs.func3()
    /.../release/tidb/br/pkg/stream/stream_metas.go:1102 +0x2c4
...

4. What is your TiDB version? (Required)

v8.5.1

Activity

  1. added
    type/bugThe issue is confirmed as a bug.
    affects-8.5This bug affects the 8.5.x(LTS) versions.
    on Sep 3, 2025
  2. kennytm commented on Sep 3, 2025

    @kennytm
    ContributorAuthor

    This bug only affects v8.5. The function does not exist on v8.1, and has been silently fixed by #56761 on v9.0.

    The cause is in here, aOut is zero-initialized, so its field aOut.NewBase is a nil pointer

    aOut := new(MigratedTo)
    m.cleanUpFor(ctx, me, aOut)

    but such field is later deferenced in

    out.NewBase.EditMeta = append(out.NewBase.EditMeta, newMetaEdit)

    so it caused the SIGSEGV.

    In v9.0 aOut.NewBase pointer is allocated:

    aOut := new(MigratedTo)
    aOut.NewBase = new(pb.Migration)
    m.cleanUpFor(ctx, me, aOut)

  3. added a commit that references this issue on Sep 18, 2025
    c832644
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-8.5This bug affects the 8.5.x(LTS) versions.component/brThis issue is related to BR of TiDB.severity/majortype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions