Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Segmentation Fault while using Lambda function with SAM Server #560

Open
sumit-popclub opened this issue Apr 30, 2024 · 1 comment

Comments

@sumit-popclub
Copy link

sumit-popclub commented Apr 30, 2024

Mounting TicketWsCmiCallback at http://127.0.0.1:3000/my-function-path [POST]
You can now browse to the above endpoints to invoke your functions. You do not
need to restart/reload SAM CLI while working on your functions, changes will be
reflected instantly/automatically. If you used sam build before running local
commands, you will need to re-run sam build for the changes to be picked up.
You only need to restart SAM CLI if you update your AWS SAM template
2024-04-30 14:45:13 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

  • Running on http://127.0.0.1:3000
    2024-04-30 14:45:13 Press CTRL+C to quit
    Invoking go-lambda (go1.x)
    Local image is up-to-date
    Using local image: public.ecr.aws/lambda/go:1-rapid-x86_64.

Mounting /Users/randomsumit/dev/sftp-server as /var/task:ro,delegated, inside
runtime container
START RequestId: a82d28f6-3ed2-484e-a42b-1754d9cd0b98 Version: $LATEST
SIGSEGV: segmentation violation
PC=0xffffffffff600400 m=4 sigcode=1 addr=0xffffffffff601000
signal arrived during cgo execution

goroutine 1 gp=0xc0000061c0 m=4 mp=0xc000080008 [syscall]:
runtime.cgocall(0x5b1071, 0xc000025e40)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/cgocall.go:157 +0x4b fp=0xc000025e18 sp=0xc000025de0 pc=0x40750b
main._Cfunc_runtime_recv_invoke(0xc0000f0008, 0xc0000f0108, 0xc0000f0207, 0xc0000f1408, 0xc0000f1d10, 0xc0000f1d18)
_cgo_gotypes.go:277 +0x4b fp=0xc000025e40 sp=0xc000025e18 pc=0x5ad60b
main.waitInvoke.func1(0xc0000f0008)
/local/p4clients/pkgbuild-de3iB/workspace/src/LambdaSandboxGoLang/src/go.amzn.com/aws-lambda-go/main.go:131 +0xaf fp=0xc000025eb0 sp=0xc000025e40 pc=0x5ae56f
main.waitInvoke()
/local/p4clients/pkgbuild-de3iB/workspace/src/LambdaSandboxGoLang/src/go.amzn.com/aws-lambda-go/main.go:131 +0x25 fp=0xc000025ef0 sp=0xc000025eb0 pc=0x5ae465
main.main()
/local/p4clients/pkgbuild-de3iB/workspace/src/LambdaSandboxGoLang/src/go.amzn.com/aws-lambda-go/main.go:61 +0x18d fp=0xc000025f50 sp=0xc000025ef0 pc=0x5adf2d
runtime.main()
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:271 +0x29d fp=0xc000025fe0 sp=0xc000025f50 pc=0x43d3dd
runtime.goexit({})
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000025fe8 sp=0xc000025fe0 pc=0x46efc1

goroutine 2 gp=0xc000006c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:402 +0xce fp=0xc00004cfa8 sp=0xc00004cf88 pc=0x43d80e
runtime.goparkunlock(...)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:408
runtime.forcegchelper()
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:326 +0xb3 fp=0xc00004cfe0 sp=0xc00004cfa8 pc=0x43d693
runtime.goexit({})
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00004cfe8 sp=0xc00004cfe0 pc=0x46efc1
created by runtime.init.6 in goroutine 1
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:314 +0x1a

goroutine 18 gp=0xc000082380 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:402 +0xce fp=0xc000048780 sp=0xc000048760 pc=0x43d80e
runtime.goparkunlock(...)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:408
runtime.bgsweep(0xc00008e000)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgcsweep.go:278 +0x94 fp=0xc0000487c8 sp=0xc000048780 pc=0x428e94
runtime.gcenable.gowrap1()
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgc.go:203 +0x25 fp=0xc0000487e0 sp=0xc0000487c8 pc=0x41d7e5
runtime.goexit({})
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc0000487e8 sp=0xc0000487e0 pc=0x46efc1
created by runtime.gcenable in goroutine 1
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgc.go:203 +0x66

goroutine 19 gp=0xc000082540 m=nil [GC scavenge wait]:
runtime.gopark(0xc00008e000?, 0x66ce60?, 0x1?, 0x0?, 0xc000082540?)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:402 +0xce fp=0xc000048f78 sp=0xc000048f58 pc=0x43d80e
runtime.goparkunlock(...)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:408
runtime.(*scavengerState).park(0x9cd9e0)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgcscavenge.go:425 +0x49 fp=0xc000048fa8 sp=0xc000048f78 pc=0x426889
runtime.bgscavenge(0xc00008e000)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgcscavenge.go:653 +0x3c fp=0xc000048fc8 sp=0xc000048fa8 pc=0x426e1c
runtime.gcenable.gowrap2()
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgc.go:204 +0x25 fp=0xc000048fe0 sp=0xc000048fc8 pc=0x41d785
runtime.goexit({})
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000048fe8 sp=0xc000048fe0 pc=0x46efc1
created by runtime.gcenable in goroutine 1
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mgc.go:204 +0xa5

goroutine 20 gp=0xc000082a80 m=nil [finalizer wait]:
runtime.gopark(0xc00004c648?, 0x411145?, 0xa8?, 0x1?, 0xc0000061c0?)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:402 +0xce fp=0xc00004c620 sp=0xc00004c600 pc=0x43d80e
runtime.runfinq()
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mfinal.go:194 +0x107 fp=0xc00004c7e0 sp=0xc00004c620 pc=0x41c827
runtime.goexit({})
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc00004c7e8 sp=0xc00004c7e0 pc=0x46efc1
created by runtime.createfing in goroutine 1
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/mfinal.go:164 +0x3d

goroutine 4 gp=0xc0000076c0 m=nil [sleep]:
runtime.gopark(0x75e8333063f?, 0x60c584?, 0x1?, 0x0?, 0xc000110230?)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/proc.go:402 +0xce fp=0xc000061f18 sp=0xc000061ef8 pc=0x43d80e
time.Sleep(0xf4240)
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/time.go:195 +0x115 fp=0xc000061f58 sp=0xc000061f18 pc=0x46bfd5
main.waitForInitialization(0xb4b5, 0xc0001e4060)
/local/p4clients/pkgbuild-de3iB/workspace/src/LambdaSandboxGoLang/src/go.amzn.com/aws-lambda-go/main.go:189 +0x85 fp=0xc000061fc0 sp=0xc000061f58 pc=0x5af505
main.newBridge.gowrap2()
/local/p4clients/pkgbuild-de3iB/workspace/src/LambdaSandboxGoLang/src/go.amzn.com/aws-lambda-go/main.go:98 +0x25 fp=0xc000061fe0 sp=0xc000061fc0 pc=0x5ae3a5
runtime.goexit({})
/opt/brazil-pkg-cache/packages/GoLang/GoLang-1.x.281226.0/AL2_x86_64/DEV.STD.PTHREAD/build/lib/src/runtime/asm_amd64.s:1695 +0x1 fp=0xc000061fe8 sp=0xc000061fe0 pc=0x46efc1
created by main.newBridge in goroutine 1
/local/p4clients/pkgbuild-de3iB/workspace/src/LambdaSandboxGoLang/src/go.amzn.com/aws-lambda-go/main.go:98 +0x259

rax 0x0
rbx 0xa43d50
rcx 0xa43d50
rdx 0x0
rdi 0x2aaafd5d8938
rsi 0x2aab00006bd0
rbp 0x0
rsp 0x2aaafd5d8928
r8 0x57e
r9 0x98da
r10 0x2aaaaaab
r11 0x0
r12 0x2aab000060b0
r13 0x0
r14 0x0
r15 0x2aaaab751ab0
rip 0xffffffffff600400
rflags 0x246
cs 0x33
fs 0x0
gs 0x0
30 Apr 2024 09:15:30,581 [ERROR] (rapid) Invoke failed error=Runtime exited with error: exit status 2 InvokeID=5fb3000b-bd74-4e23-a96c-373981bdb756
30 Apr 2024 09:15:30,586 [ERROR] (rapid) Invoke DONE failed: Runtime.ExitError

2024-04-30 14:45:31 127.0.0.1 - - [30/Apr/2024 14:45:31] "POST /my-function-path HTTP/1.1" 500

This is my code -

package main

import (
	"context"
	"fmt"
	"log"
	"net/url"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
)

func handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
	// Parse form data from the request body
	parsedFormData, err := url.ParseQuery(request.Body)
	if err != nil {
		log.Printf("Error parsing form data: %s", err)
		return events.APIGatewayProxyResponse{StatusCode: 400}, err
	}

	// Access POST parameters
	key1 := parsedFormData.Get("key1")
	key2 := parsedFormData.Get("key2")

	log.Printf("Received Key1: %s", key1)
	log.Printf("Received Key2: %s", key2)

	return events.APIGatewayProxyResponse{
		StatusCode: 200,
		Body:       fmt.Sprintf(`%s %s`, key1, key2),
	}, nil
}

func main() {
	lambda.Start(handler)
}
@sumit-popclub sumit-popclub changed the title Getting this error while setting up local SAM server for testing AWS-Lambda Getting Segmentation Fault while using Lambda function with SAM Server Apr 30, 2024
@TalalM
Copy link

TalalM commented Dec 4, 2024

I have the same issue. I get the error even with an empty handler.

Using version SAM CLI, version 1.131.0.

@sumit-popclub did you manage to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants