在一些特定的情况下Close会报空引用 #1176

Open
opened 2018-12-17 10:39:01 +00:00 by wenbingzhang · 4 comments
wenbingzhang commented 2018-12-17 10:39:01 +00:00 (Migrated from github.com)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x648e82]

goroutine 1 [running]:
...github.com/go-xorm/xorm.(*Engine).Close(0x0, 0x7, 0x7f3273cd2390)
	.../github.com/go-xorm/xorm/engine.go:318 +0x22

在特定的环境下会报空引用,建议在Close()下加上空引用检查

``` panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x648e82] goroutine 1 [running]: ...github.com/go-xorm/xorm.(*Engine).Close(0x0, 0x7, 0x7f3273cd2390) .../github.com/go-xorm/xorm/engine.go:318 +0x22 ``` 在特定的环境下会报空引用,建议在Close()下加上空引用检查

Could you show how did you use Engine and Engine.Close?

Could you show how did you use `Engine` and `Engine`.Close?
wenbingzhang commented 2018-12-19 12:51:16 +00:00 (Migrated from github.com)

你能说明你是如何使用Engine和。Engine关闭的吗?

linux

cat /etc/sysctl.conf | grep -v -e "^#" -e "^$"
fs.file-max = 1024

打开最大文件数比较小,并发超过的时候会出现这个问题。

> 你能说明你是如何使用`Engine`和。`Engine`关闭的吗? linux ``` cat /etc/sysctl.conf | grep -v -e "^#" -e "^$" fs.file-max = 1024 ``` 打开最大文件数比较小,并发超过的时候会出现这个问题。

Please show codes about how you are using Engine here.

Please show codes about how you are using `Engine` here.
wenbingzhang commented 2018-12-21 01:35:13 +00:00 (Migrated from github.com)

Please show codes about how you are using Engine here.

1、在main中我使用了 defer engine.Close(),然后10个协程并发处理数据库。其他的就是正常的增删改查了。
2、没有显示使用engine.NewSession()方法。
3、没在main以外的任何地方使用engine.Close()
4、当时我还在用其他程序测试多线程并发,线程数超过了fs.file-max=1024的值。

> Please show codes about how you are using `Engine` here. 1、在main中我使用了 defer engine.Close(),然后10个协程并发处理数据库。其他的就是正常的增删改查了。 2、没有显示使用engine.NewSession()方法。 3、没在main以外的任何地方使用engine.Close() 4、当时我还在用其他程序测试多线程并发,线程数超过了fs.file-max=1024的值。
Sign in to join this conversation.
No Milestone
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: xorm/xorm#1176
No description provided.