Investigate crash #9

Open
opened 2024-04-22 18:18:42 +00:00 by marco · 1 comment
Owner
2024/04/22 19:41:06 GameState =  3
2024/04/22 19:41:06 GameState =  4
2024/04/22 19:41:06 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":4,"row":8},"endSquare":{"col":3,"row":8},"ColorMoved":"black","PieceMoved":"q"},"turnColor":"white","playerColor":"white","position":"RNB--K-R/PPnP--B-/----P---/----pPQ-/---p----/--------/ppp--ppp/r-q--rk-"}
2024/04/22 19:41:06 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":4,"row":8},"endSquare":{"col":3,"row":8},"ColorMoved":"black","PieceMoved":"q"},"turnColor":"white","playerColor":"black","position":"RNB--K-R/PPnP--B-/----P---/----pPQ-/---p----/--------/ppp--ppp/r-q--rk-"}
2024/04/22 19:41:06 GameState =  2
2024/04/22 19:41:06 with  white  to move
2024/04/22 19:41:30 Reading message: {"messageType":"move","move":{"startSquare":{"col":7,"row":4},"endSquare":{"col":8,"row":5},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6
2024/04/22 19:41:30 Player  &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0}  moved:
 {{7 4} {8 5} <nil>  }
2024/04/22 19:41:30 GameState =  3
2024/04/22 19:41:30 GameState =  4
2024/04/22 19:41:30 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":7,"row":4},"endSquare":{"col":8,"row":5},"ColorMoved":"white","PieceMoved":"Q"},"turnColor":"black","playerColor":"white","position":"RNB--K-R/PPnP--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"}
2024/04/22 19:41:30 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":7,"row":4},"endSquare":{"col":8,"row":5},"ColorMoved":"white","PieceMoved":"Q"},"turnColor":"black","playerColor":"black","position":"RNB--K-R/PPnP--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"}
2024/04/22 19:41:30 GameState =  2
2024/04/22 19:41:30 with  black  to move
2024/04/22 19:41:37 Reading message: {"messageType":"move","move":{"startSquare":{"col":3,"row":2},"endSquare":{"col":1,"row":1},"promotionToPiece":null},"color":null} from player d7c5eb38-2886-42f7-ab3c-629a13a1f2cc
2024/04/22 19:41:37 Player  &{d7c5eb38-2886-42f7-ab3c-629a13a1f2cc 0xc00011d6c0 black 0x6821a0}  moved:
 {{3 2} {1 1} <nil>  }
2024/04/22 19:41:37 GameState =  3
2024/04/22 19:41:37 GameState =  4
2024/04/22 19:41:37 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":3,"row":2},"endSquare":{"col":1,"row":1},"ColorMoved":"black","PieceMoved":"n"},"turnColor":"white","playerColor":"white","position":"nNB--K-R/PP-P--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"}
2024/04/22 19:41:37 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":3,"row":2},"endSquare":{"col":1,"row":1},"ColorMoved":"black","PieceMoved":"n"},"turnColor":"white","playerColor":"black","position":"nNB--K-R/PP-P--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"}
2024/04/22 19:41:37 GameState =  2
2024/04/22 19:41:37 with  white  to move
2024/04/22 19:43:05 Reading message: {"messageType":"move","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":7,"row":8},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6
2024/04/22 19:43:05 Player  &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0}  moved:
 {{8 5} {7 8} <nil>  }
2024/04/22 19:43:05 GameState =  3
2024/04/22 19:43:05 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":7,"row":8},"ColorMoved":"white","PieceMoved":"Q"},"reason":"invalid move"}
2024/04/22 19:43:05 with  white  to move
2024/04/22 19:44:07 while reading from websocket: %w failed to get reader: failed to read frame header: read tcp 85.214.118.93:9999->109.43.112.11:5339: read: connection timed out
2024/04/22 19:44:07 black  disconnected
2024/04/22 19:44:56 Reading message: {"messageType":"move","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":8,"row":8},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6
2024/04/22 19:44:56 Player  &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0}  moved:
 {{8 5} {8 8} <nil>  }
2024/04/22 19:44:56 GameState =  3
2024/04/22 19:44:56 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":8,"row":8},"ColorMoved":"white","PieceMoved":"Q"},"reason":"invalid move"}
2024/04/22 19:44:56 with  white  to move
2024/04/22 19:45:29 Reading message: {"messageType":"move","move":{"startSquare":{"col":5,"row":3},"endSquare":{"col":3,"row":1},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6
2024/04/22 19:45:29 Player  &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0}  moved:
 {{5 3} {3 1} <nil>  }
2024/04/22 19:45:29 GameState =  3
2024/04/22 19:45:29 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":5,"row":3},"endSquare":{"col":3,"row":1},"ColorMoved":"white","PieceMoved":"P"},"reason":"target square is occupied"}
2024/04/22 19:45:29 with  white  to move
2024/04/22 19:45:36 Reading message: {"messageType":"move","move":{"startSquare":{"col":3,"row":1},"endSquare":{"col":3,"row":5},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6
2024/04/22 19:45:36 Player  &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0}  moved:
 {{3 1} {3 5} <nil>  }
2024/04/22 19:45:36 GameState =  3
2024/04/22 19:45:36 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":3,"row":1},"endSquare":{"col":3,"row":5},"ColorMoved":"white","PieceMoved":"B"},"reason":"invalid move"}
2024/04/22 19:45:36 with  white  to move
2024/04/22 19:45:49 Reading message: {"messageType":"move","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":6,"row":7},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6
2024/04/22 19:45:49 Player  &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0}  moved:
 {{8 5} {6 7} <nil>  }
2024/04/22 19:45:49 GameState =  3
2024/04/22 19:45:49 GameState =  4
2024/04/22 19:45:49 Game should be killed
panic: runtime error: index out of range [1] with length 1

goroutine 784 [running]:
mchess_server/chess.(*Game).Handle(0xc00038e680)
        /opt/mchess_server/chess/game.go:130 +0xb85
created by mchess_server/chess.(*Game).StartHandling in goroutine 782
        /opt/mchess_server/chess/game.go:82 +0x59
``` {{4 8} {3 8} <nil> } 2024/04/22 19:41:06 GameState = 3 2024/04/22 19:41:06 GameState = 4 2024/04/22 19:41:06 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":4,"row":8},"endSquare":{"col":3,"row":8},"ColorMoved":"black","PieceMoved":"q"},"turnColor":"white","playerColor":"white","position":"RNB--K-R/PPnP--B-/----P---/----pPQ-/---p----/--------/ppp--ppp/r-q--rk-"} 2024/04/22 19:41:06 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":4,"row":8},"endSquare":{"col":3,"row":8},"ColorMoved":"black","PieceMoved":"q"},"turnColor":"white","playerColor":"black","position":"RNB--K-R/PPnP--B-/----P---/----pPQ-/---p----/--------/ppp--ppp/r-q--rk-"} 2024/04/22 19:41:06 GameState = 2 2024/04/22 19:41:06 with white to move 2024/04/22 19:41:30 Reading message: {"messageType":"move","move":{"startSquare":{"col":7,"row":4},"endSquare":{"col":8,"row":5},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6 2024/04/22 19:41:30 Player &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0} moved: {{7 4} {8 5} <nil> } 2024/04/22 19:41:30 GameState = 3 2024/04/22 19:41:30 GameState = 4 2024/04/22 19:41:30 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":7,"row":4},"endSquare":{"col":8,"row":5},"ColorMoved":"white","PieceMoved":"Q"},"turnColor":"black","playerColor":"white","position":"RNB--K-R/PPnP--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"} 2024/04/22 19:41:30 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":7,"row":4},"endSquare":{"col":8,"row":5},"ColorMoved":"white","PieceMoved":"Q"},"turnColor":"black","playerColor":"black","position":"RNB--K-R/PPnP--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"} 2024/04/22 19:41:30 GameState = 2 2024/04/22 19:41:30 with black to move 2024/04/22 19:41:37 Reading message: {"messageType":"move","move":{"startSquare":{"col":3,"row":2},"endSquare":{"col":1,"row":1},"promotionToPiece":null},"color":null} from player d7c5eb38-2886-42f7-ab3c-629a13a1f2cc 2024/04/22 19:41:37 Player &{d7c5eb38-2886-42f7-ab3c-629a13a1f2cc 0xc00011d6c0 black 0x6821a0} moved: {{3 2} {1 1} <nil> } 2024/04/22 19:41:37 GameState = 3 2024/04/22 19:41:37 GameState = 4 2024/04/22 19:41:37 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":3,"row":2},"endSquare":{"col":1,"row":1},"ColorMoved":"black","PieceMoved":"n"},"turnColor":"white","playerColor":"white","position":"nNB--K-R/PP-P--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"} 2024/04/22 19:41:37 Writing message: {"messageType":"boardState","move":{"startSquare":{"col":3,"row":2},"endSquare":{"col":1,"row":1},"ColorMoved":"black","PieceMoved":"n"},"turnColor":"white","playerColor":"black","position":"nNB--K-R/PP-P--B-/----P---/----pP--/---p---Q/--------/ppp--ppp/r-q--rk-"} 2024/04/22 19:41:37 GameState = 2 2024/04/22 19:41:37 with white to move 2024/04/22 19:43:05 Reading message: {"messageType":"move","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":7,"row":8},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6 2024/04/22 19:43:05 Player &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0} moved: {{8 5} {7 8} <nil> } 2024/04/22 19:43:05 GameState = 3 2024/04/22 19:43:05 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":7,"row":8},"ColorMoved":"white","PieceMoved":"Q"},"reason":"invalid move"} 2024/04/22 19:43:05 with white to move 2024/04/22 19:44:07 while reading from websocket: %w failed to get reader: failed to read frame header: read tcp 85.214.118.93:9999->109.43.112.11:5339: read: connection timed out 2024/04/22 19:44:07 black disconnected 2024/04/22 19:44:56 Reading message: {"messageType":"move","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":8,"row":8},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6 2024/04/22 19:44:56 Player &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0} moved: {{8 5} {8 8} <nil> } 2024/04/22 19:44:56 GameState = 3 2024/04/22 19:44:56 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":8,"row":8},"ColorMoved":"white","PieceMoved":"Q"},"reason":"invalid move"} 2024/04/22 19:44:56 with white to move 2024/04/22 19:45:29 Reading message: {"messageType":"move","move":{"startSquare":{"col":5,"row":3},"endSquare":{"col":3,"row":1},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6 2024/04/22 19:45:29 Player &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0} moved: {{5 3} {3 1} <nil> } 2024/04/22 19:45:29 GameState = 3 2024/04/22 19:45:29 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":5,"row":3},"endSquare":{"col":3,"row":1},"ColorMoved":"white","PieceMoved":"P"},"reason":"target square is occupied"} 2024/04/22 19:45:29 with white to move 2024/04/22 19:45:36 Reading message: {"messageType":"move","move":{"startSquare":{"col":3,"row":1},"endSquare":{"col":3,"row":5},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6 2024/04/22 19:45:36 Player &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0} moved: {{3 1} {3 5} <nil> } 2024/04/22 19:45:36 GameState = 3 2024/04/22 19:45:36 Writing message: {"messageType":"invalidMove","move":{"startSquare":{"col":3,"row":1},"endSquare":{"col":3,"row":5},"ColorMoved":"white","PieceMoved":"B"},"reason":"invalid move"} 2024/04/22 19:45:36 with white to move 2024/04/22 19:45:49 Reading message: {"messageType":"move","move":{"startSquare":{"col":8,"row":5},"endSquare":{"col":6,"row":7},"promotionToPiece":null},"color":null} from player 44b80fa6-82b3-4db7-8411-1b864f8948b6 2024/04/22 19:45:49 Player &{44b80fa6-82b3-4db7-8411-1b864f8948b6 0xc00011cb60 white 0x6821a0} moved: {{8 5} {6 7} <nil> } 2024/04/22 19:45:49 GameState = 3 2024/04/22 19:45:49 GameState = 4 2024/04/22 19:45:49 Game should be killed panic: runtime error: index out of range [1] with length 1 goroutine 784 [running]: mchess_server/chess.(*Game).Handle(0xc00038e680) /opt/mchess_server/chess/game.go:130 +0xb85 created by mchess_server/chess.(*Game).StartHandling in goroutine 782 /opt/mchess_server/chess/game.go:82 +0x59 ```
Author
Owner

I think, when one player disconnects and the state changes to CheckPlayerChange the player slice only consists of one element and a bound violation occurs.

I think, when one player disconnects and the state changes to `CheckPlayerChange` the player slice only consists of one element and a bound violation occurs.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: marco/mchess-server#9
No description provided.