Skip to content

Nil deref in index handler #9234

Closed
Closed

Description

@imsodin

Panic were reported in android a few times and then here an actual/ful panic trace was referenced:
https://forum.syncthing.net/t/syncthing-1-26-crashing-on-android-in-syncthing-fork/21115/2

11-19 11:32:51.661 11506 21478 W SyncthingNativeCode: panic: runtime error: invalid memory address or nil pointer dereference
11-19 11:32:51.661 11506 21478 W SyncthingNativeCode: [signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x637d5ee060]
11-19 11:32:51.661 11506 21478 W SyncthingNativeCode:
11-19 11:32:51.661 11506 21478 W SyncthingNativeCode: goroutine 325 [running]:
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model.(*indexHandlerRegistry).startLocked(, {{0x4000363e44, 0xc}, {0x4000363e70, 0xc}, 0x0, {0x400011af78, 0x18}, 0x1, {0x40000c2b40, ...}, ...}, ...)
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model/indexhandler.go:419 +0x100
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model.(*indexHandlerRegistry).AddIndexInfo(0x400040e370, {0x40001307b0, 0xc}, 0x4000000640)
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model/indexhandler.go:439 +0x430
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model.(*model).ccHandleFolders(
, {_, _, _}, {{0xdb, 0xa, 0xa4, 0x47, 0xc6, 0x6f, ...}, ...}, ...)
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model/model.go:1496 +0x5a8
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model.(*model).ClusterConfig(0x40001c6180, {0x637d8d4148, 0x4000eec350}, {{0x400154ca00?, 0x40000e8088?, 0x40000e8088?}, 0x68?})
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/model/model.go:1296 +0x784
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol.(*connectionWrappingModel).ClusterConfig(0x4000bc5d68?, {{0x400154ca00?, 0x10?, 0x637d710540?}, 0x1?})
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol/protocol.go:1143 +0x50
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol.encryptedModel.ClusterConfig(...)
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol/encryption.go:155
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol.(*rawConnection).dispatcherLoop(0x4000116a20)
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol/protocol.go:496 +0x308
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol.(*rawConnection).Start.func2()
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol/protocol.go:307 +0x24
11-19 11:32:51.663 21476 0 E Go : created by github.com/syncthing/syncthing/lib/protocol.(*rawConnection).Start
11-19 11:32:51.663 21476 0 E Go : github.com/syncthing/syncthing/lib/protocol/protocol.go:306 +0x144
11-19 11:32:51.663 21476 0 E Go :

There's recently changed/added code that sets up index handlers and access fmut protected fields without holding the lock: https://github.com/syncthing/syncthing/blob/main/lib/model/model.go#L1370
I don't see how exactly this can lead to the panic, but presumably some race around pausing a folder.

I am sending a PR shortly.

Activity

  1. added
    bug
    needs-triage
    and removed
    needs-triage
    on Nov 19, 2023
  2. added a commit that references this issue on Nov 19, 2023
    75d5684
  3. added a commit that references this issue on Dec 5, 2023
    48ec761
  4. added this to the v1.27.0 milestone on Dec 7, 2023
  5. reopened this on Dec 7, 2023
  6. imsodin commented on Dec 7, 2023

    @imsodin
    MemberAuthor

    Unfortunately this is still happening in 1.27.0, as reported here:
    https://forum.syncthing.net/t/syncthing-1-26-crashing-on-android-in-syncthing-fork/21115/12

    Same panic.

    I already have a new thing to fix :)

  7. added a commit that references this issue on Dec 7, 2023
    3fc3926
  8. imsodin commented on Dec 7, 2023

    @imsodin
    MemberAuthor

    New issue is where we track this, this stays closed :)
    #9269

  9. added a commit that references this issue on Jan 28, 2024
    958ff67
  10. added
    frozen-due-to-age
    on Apr 9, 2025
  11. locked and limited conversation to collaborators on Apr 9, 2025
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

    bugfrozen-due-to-age

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions