Skip to content

[Bug] 🐛 AZ部署API调用报错invalid memory address or nil pointer dereference #406

Closed
@chaoyu1999

Description

@chaoyu1999

Confirmations

  • 我确认我已经仔细阅读了 Wiki, 并且已经搜索了已有的 issue, 并没有类似问题。

Describe the bug

AZ部署,网页可用,API调用报错。
image

Steps to reproduce

None

Expected behavior

None

Screenshots

image

2024-04-25T11:55:00.6177037Z 2024/04/25 11:55:00 http: panic serving 169.254.129.1:60811: runtime error: invalid memory address or nil pointer dereference
2024-04-25T11:55:00.6190027Z goroutine 3555 [running]:
2024-04-25T11:55:00.6198773Z net/http.(*conn).serve.func1()
2024-04-25T11:55:00.6208414Z 	net/http/server.go:1898 +0xbe
2024-04-25T11:55:00.6217835Z panic({0x89bc80?, 0xe93fe0?})
2024-04-25T11:55:00.6225098Z 	runtime/panic.go:770 +0x132
2024-04-25T11:55:00.6230953Z github.com/Harry-zklcdc/bing-lib.(*Chat).Clone(...)
2024-04-25T11:55:00.6237495Z 	github.com/Harry-zklcdc/bing-lib@v1.6.8/chat.go:68
2024-04-25T11:55:00.6243304Z adams549659584/go-proxy-bingai/common/api/v1.ChatHandler({0xb77060, 0xc000bea738}, 0xc0001586c0)
2024-04-25T11:55:00.6248999Z 	adams549659584/go-proxy-bingai/common/api/v1/chat.go:53 +0x68d
2024-04-25T11:55:00.6259910Z 2024-04-25 11:55:00,617 CRIT uncaptured python exception, closing channel <POutputDispatcher at 126211706486944 for <Subprocess at 126211706211296 with name go-proxy-bingai in state RUNNING> (stderr)> (<class 'OSError'>:[Errno 29] Illegal seek [/usr/lib/python3/dist-packages/supervisor/supervisord.py|runforever|220] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|handle_read_event|270] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|record_output|204] [/usr/lib/python3/dist-packages/supervisor/dispatchers.py|_log|173] [/usr/lib/python3/dist-packages/supervisor/loggers.py|info|327] [/usr/lib/python3/dist-packages/supervisor/loggers.py|log|345] [/usr/lib/python3/dist-packages/supervisor/loggers.py|emit|227] [/usr/lib/python3/dist-packages/supervisor/loggers.py|doRollover|264])
2024-04-25T11:55:00.6276235Z main.main.Middleware.func1({0xb771e0?, 0xc000be67e0?}, 0xc0001586c0)
2024-04-25T11:55:00.6282811Z 	adams549659584/go-proxy-bingai/common/helper/middleware.go:48 +0xb2
2024-04-25T11:55:00.6293040Z net/http.HandlerFunc.ServeHTTP(0xea8d10?, {0xb771e0?, 0xc000be67e0?}, 0x10?)
2024-04-25T11:55:00.6303887Z 	net/http/server.go:2166 +0x29
2024-04-25T11:55:00.6312514Z net/http.(*ServeMux).ServeHTTP(0x40e805?, {0xb771e0, 0xc000be67e0}, 0xc0001586c0)
2024-04-25T11:55:00.6321283Z 	net/http/server.go:2683 +0x1ad
2024-04-25T11:55:00.6330128Z net/http.serverHandler.ServeHTTP({0xb75d78?}, {0xb771e0?, 0xc000be67e0?}, 0x6?)
2024-04-25T11:55:00.6338965Z 	net/http/server.go:3137 +0x8e
2024-04-25T11:55:00.6348617Z net/http.(*conn).serve(0xc000194ab0, {0xb78178, 0xc0001ea510})
2024-04-25T11:55:00.6356612Z 	net/http/server.go:2039 +0x5e8
2024-04-25T11:55:00.6363738Z created by net/http.(*Server).Serve in goroutine 1
2024-04-25T11:55:00.6370745Z 	net/http/server.go:3285 +0x4b4

GPT解释:
错误描述显示,服务器在处理来自地址 169.254.129.1:39407 的请求时遇到了 panic,这意味着程序在运行时发生了严重错误,导致了异常终止。具体的错误是由于“空指针解引用”(nil pointer dereference)引起的,这通常表示代码尝试访问一个未初始化或已经被释放的内存地址。

从堆栈跟踪中可以看到,这个错误发生在 github.com/Harry-zklcdc/bing-lib.(*Chat).Clone 函数中。这可能是因为这个函数尝试调用一个未初始化的对象或结构体上的方法,导致访问了一个空指针。

解决方法:

  1. 检查 Clone 函数:确保在调用该函数之前,所有必要的对象和结构体都已经正确初始化。
  2. 添加空指针检查:在 Clone 函数或相关代码中添加检查,以确保在使用指针之前它们不是空的。
  3. 审查代码:确保在整个代码中都适当地检查了可能为空的指针,避免在运行时出现这样的错误。

根据具体的代码和场景,这些建议可能需要调整。希望这些信息有助于您解决问题。

Deploy

Others

UserId

No response

OS & Version

win10

Browser & Version

edge

GoProxiBingAI Version

docker-last

Additional context

No response

Activity

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

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions