stratux icon indicating copy to clipboard operation
stratux copied to clipboard

Lock required around MsgLog in gen_gdl90.go

Open ssokol opened this issue 3 years ago • 0 comments

  1. Stratux version: v1.6r1

  2. Stratux config:

    SDR

    • [ ] single
    • [X] dual

    GPS

    • [X] yes
    • [ ] no type:

    AHRS

    • [X] yes
    • [ ] no

    power source: ship's power via 2.5 amp buck reg

    usb cable: n/a

  3. EFB app and version: (e.g., WingX Pro7 8.6.2) - FlightView

    EFB platform: (e.g., iOS 9.2) - iOS 14.4

    EFB hardware: (e.g., iPad Mini 2) - n/a

  4. Description of your issue:

This is a rare (I've seen it twice in hundreds of hours of operations) crash caused by the loop in the function that processes the message log into stats coming up short (index off by 1) due to another Go routine making changes to the array while the stats generator is running. Here's the output:

panic: runtime error: index out of range [13132] with length 13132

goroutine 43 [running]:
main.updateMessageStats()
	/root/flightbox/main/gen_gdl90.go:831 +0x7c8
main.heartBeatSender()
	/root/flightbox/main/gen_gdl90.go:809 +0x3b4
created by main.main
	/root/flightbox/main/gen_gdl90.go:1956 +0xd2c

The line numbers are a bit off from the official 1.6 build as this is running in my fork, but the code in question hasn't changed.

I think the solution here is to wrap a read/write mutex (RWMutex) around any changes to the MsgLog array.

If possible, enable "Replay Logs", reproduce the problem, and provide a copy of the logs in http://192.168.10.1/logs/stratux/ and http://192.168.10.1/logs/stratux.log.

ssokol avatar Apr 03 '21 14:04 ssokol