aws/aws-lambda-runtime-interface-emulator

RIE crashes with null pointer dereference after logging `AlreadyReserved` error

valeneiko opened this issue · 1 comments

AWS Lambda runtime interface emulator crashes with null pointer dereference after logging AlreadyReserved error. I was not able to reproduce this locally, but it consistently crashes in our CI.

Here are the logs from the container:

START RequestId: ed9ab7c3-58ce-4bca-926-313ad04e10a2 Version: $LATEST
19 Jul 2024 13:55:28,399 [INFO] (rapid) INVOKE START(requestId: 8a4bf007-ab1b-4650-8773-f17bfaa0ab57)
START RequestId: 9970c39-0b00-4b40-a786-224952815d2a Version: $LATEST
19 Jul 2024 13:55:28,580 [INFO] (rapid) ReserveFailed: AlreadyReserved
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6b3d9f]

goroutine 102 [running]:
go.amzn.com/lambda/rapidcore.(*Server).Invoke.func2()
  /LambdaRuntimeLocal/lambda/rapidcore/server.go:666 +0xdf
created by go.amzn.com/lambda/rapidcore.(*Server).Invoke in goroutine 113
  /LambdaRuntimeLocal/lambda/rapidcore/server.go:649 +0x1f1

Null pointer dereference happens here:

reserveResp, err := s.Reserve("", "", "")
if err != nil {
log.Infof("ReserveFailed: %s", err)
}
invoke.DeadlineNs = fmt.Sprintf("%d", metering.Monotime()+reserveResp.Token.FunctionTimeout.Nanoseconds())

s.Reserve() can return reserveResp = nil in case of an error returned from here:

if s.invokeCtx != nil {
return nil, ErrAlreadyReserved
}

Duplicate of: