在非保护分支向保护分支发起PR导致gogs崩溃退出


#1

请先搜索确保没有重复发帖。

Gogs 版本:0.11.34
系统类型及版本:16.04 LTS /// 4.13.0-38-generic #43~16.04.1-Ubuntu SMP Wed Mar 14 17:48:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
数据库:Postgresql 9.6
git版本 2.17.0
问题描述:
在某些分支 没发现规律 向保护分支发起PR的时候 gogs进程就退出了 用strace跟了一下:

epoll_wait(4, [{EPOLLOUT, {u32=729476016, u64=140523469466544}}], 128, 0) = 1
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
epoll_wait(4, [], 128, 0) = 0
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
epoll_wait(4, [], 128, 0) = 0
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
epoll_wait(4, [{EPOLLIN|EPOLLOUT, {u32=729476400, u64=140523469466928}}], 128, -1) = 1
futex(0x18eac78, FUTEX_WAKE, 1) = 1
futex(0x18eabb0, FUTEX_WAKE, 1) = 1
read(7, “1\0\0\0\4t\0\0\0\n\0\1\0\0\0\31T\0\0\3\303\0!id\0\0\0A\230\0\1”…, 4096) = 986
write(7, “B\0\0\0[\0\0\0\0\0\1\0\0\0\thuilianyi\0!\0\1\0\0\0\0”…, 107) = 107
read(7, 0xc420505000, 4096) = -1 EAGAIN (Resource temporarily unavailable)
epoll_wait(4, [], 128, 0) = 0
epoll_wait(4, [{EPOLLIN|EPOLLOUT, {u32=729476400, u64=140523469466928}}], 128, -1) = 1
futex(0x18eac78, FUTEX_WAKE, 1) = 1
futex(0x18eabb0, FUTEX_WAKE, 1) = 1
read(7, “2\0\0\0\4D\0\0\0\373\0!\0\0\0\10\0\0\0\0\0\0\0\4\0\0\0\thuil”…, 4096) = 277
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
write(6, “P\0\0\2\301\0SELECT “id”, “owner_id”, “”…, 718) = 718
read(6, 0xc420504000, 4096) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
epoll_wait(4, [], 128, 0) = 0
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0xc420062110, FUTEX_WAKE, 1) = 1
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
epoll_wait(4, [], 128, 0) = 0
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
epoll_wait(4, [], 128, 0) = 0
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0xc420062110, FUTEX_WAKE, 1) = 1
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc420028b90, FUTEX_WAKE, 1) = 1
read(13, 0xc422024600, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc420028b90, FUTEX_WAKE, 1) = 1
read(13, 0xc42271ba00, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc420028810, FUTEX_WAKE, 1) = 1
read(13, 0xc421f67400, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc4204a2110, FUTEX_WAKE, 1) = 1
read(13, 0xc422996000, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
read(15, “”, 512) = 0
epoll_ctl(4, EPOLL_CTL_DEL, 15, 0xc4205635f4) = 0
close(15) = 0
futex(0xc420028810, FUTEX_WAKE, 1) = 1
stat(”/usr/local/sbin/git", 0xc4214bba38) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/git", 0xc4214bbb08) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/git", 0xc4214bbbd8) = -1 ENOENT (No such file or directory)
stat("/usr/bin/git", {st_mode=S_IFREG|0755, st_size=2231024, …}) = 0
openat(AT_FDCWD, “/dev/null”, O_RDONLY|O_CLOEXEC) = 12
epoll_ctl(4, EPOLL_CTL_ADD, 12, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=729475056, u64=140523469465584}}) = -1 EPERM (Operation not permitted)
epoll_ctl(4, EPOLL_CTL_DEL, 12, 0xc421e107cc) = -1 EPERM (Operation not permitted)
pipe2([13, 14], O_CLOEXEC) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 13, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=729475056, u64=140523469465584}}) = 0
fcntl(13, F_GETFL) = 0 (flags O_RDONLY)
fcntl(13, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 14, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=729474096, u64=140523469464624}}) = 0
fcntl(14, F_GETFL) = 0x1 (flags O_WRONLY)
fcntl(14, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
pipe2([15, 16], O_CLOEXEC) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 15, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=729474864, u64=140523469465392}}) = 0
fcntl(15, F_GETFL) = 0 (flags O_RDONLY)
fcntl(15, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 16, {EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET, {u32=729473712, u64=140523469464240}}) = 0
fcntl(16, F_GETFL) = 0x1 (flags O_WRONLY)
fcntl(16, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
stat("/data/gogs/repositories/test/test.git", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
fcntl(14, F_GETFL) = 0x801 (flags O_WRONLY|O_NONBLOCK)
fcntl(14, F_SETFL, O_WRONLY) = 0
fcntl(16, F_GETFL) = 0x801 (flags O_WRONLY|O_NONBLOCK)
fcntl(16, F_SETFL, O_WRONLY) = 0
pipe2([17, 18], O_CLOEXEC) = 0
getpid() = 5621
rt_sigprocmask(SIG_SETMASK, NULL, [], 8) = 0
rt_sigprocmask(SIG_SETMASK, ~[], NULL, 8) = 0
clone(child_stack=0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 5801
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
close(18) = 0
read(17, “”, 8) = 0
close(17) = 0
close(12) = 0
epoll_ctl(4, EPOLL_CTL_DEL, 14, 0xc421e108d4) = 0
close(14) = 0
epoll_ctl(4, EPOLL_CTL_DEL, 16, 0xc421e108d4) = 0
close(16) = 0
futex(0xc420028810, FUTEX_WAKE, 1) = 1
waitid(P_PID, 5801, {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=5801, si_uid=1000, si_status=0, si_utime=0, si_stime=0}, WEXITED|WNOWAIT, NULL) = 0
wait4(5801, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, {ru_utime={0, 1247}, ru_stime={0, 0}, …}) = 5801
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
write(6, "P\0\0\0k\0SELECT “id”, “user_id”, “r”…, 120) = 120
read(6, 0xc420504000, 4096) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
epoll_wait(4, [{EPOLLOUT, {u32=729475056, u64=140523469465584}}, {EPOLLOUT, {u32=729474096, u64=140523469464624}}], 128, 0) = 2
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
read(13, 0xc422996400, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
read(13, 0xc421f67800, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
read(13, 0xc422a02000, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc420028b90, FUTEX_WAKE, 1) = 1
read(13, 0xc422024e00, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
read(13, 0xc422025400, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0xc4225ac490, FUTEX_WAKE, 1) = 1
read(13, 0xc421f67e00, 512) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = -1 EAGAIN (Resource temporarily unavailable)
pselect6(0, NULL, NULL, NULL, {0, 3000}, NULL) = 0 (Timeout)
futex(0xc420028b90, FUTEX_WAKE, 1) = 1
futex(0x18ebb10, FUTEX_WAIT, 0, NULL) = 0
futex(0x18ebb10, FUTEX_WAIT, 0, NULL <unfinished …>
+++ exited with 2 +++

升级到最新版 11.43 git退到2.7.4 还是没用 拿到了退出时的报错

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x82636c]

goroutine 1336 [running]:
githubcom/gogits/gogs/vendor/githubcom/gogits/git-module.ParsePatch(0xc4214b6b40, 0x1f4, 0xc8, 0x14, 0xfb9840, 0xc422b62000, 0xc4214f33e0)
/home/vagrant/gopath/src/githubcom/gogits/gogs/vendor/githubcom/gogits/git-module/repo_diff.go:178 +0x2fc
githubcom/gogits/gogs/vendor/githubcom/gogits/git-module.GetDiffRange.func1(0xc4214b6b40, 0x1f4, 0xc8, 0x14, 0xc422b62000, 0xc422b62010)
/home/vagrant/gopath/src/githubcom/gogits/gogs/vendor/githubcom/gogits/git-module/repo_diff.go:336 +0x63
created by githubcom/gogits/gogs/vendor/githubcom/gogits/git-module.GetDiffRange
/home/vagrant/gopath/src/githubcom/gogits/gogs/vendor/githubcom/gogits/git-module/repo_diff.go:335 +0x32

发现问题了 是app.ini里这两个值设置不当引起的 应该是如下设置
MAX_GIT_DIFF_LINES = 500
MAX_GIT_DIFF_LINE_CHARACTERS = 200
MAX_GIT_DIFF_FILES =50

同时想问一下 GC_ARGS = 的准确写法
GC_ARGS = “–aggressive --auto”
GC_ARGS = --aggressive --auto

上面2种 哪一种是正确的?无论哪一种 都不会admin后台显示


#2

补充下 git version 2.17.0


#3

试了最新版 gogs 了吗。。至少 0.11.43


#4

最新43试过的 同样的问题
我的标题描述不太正确 应该是diff就会崩溃退出 把参数设置成这样

MAX_GIT_DIFF_LINES = 1
MAX_GIT_DIFF_LINE_CHARACTERS = 1
MAX_GIT_DIFF_FILES =1

还有另外一个问题 有时候PR会报500 日志报

2018/04/27 10:07:04 [ERROR] […g/context/context.go:171 ServerError()] Merge: git checkout ‘namespace/hotifx-next’: error: pathspec ‘namespace/hotfix-next’ did not match any file(s) known to git.

这种有什么办法在linux的终端上调试吗

目前发现一个保护分支有问题 另外一个没有 有问题的分支新开一个出来 也是有问题

用strace看了下文件操作 base branch 好像是data/tmp/local-repo/27 是不是名字错了?
strace -e trace=file -p $pid
strace: Process 20019 attached
newfstatat(AT_FDCWD, “/usr/local/sbin/git”, 0xc4205b2518, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/local/bin/git”, 0xc4205b25e8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/sbin/git”, 0xc4205b26b8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/bin/git”, {st_mode=S_IFREG|0755, st_size=2231024, …}, 0) = 0
openat(AT_FDCWD, “/dev/null”, O_RDONLY|O_CLOEXEC) = 11
newfstatat(AT_FDCWD, “data/tmp/local-repo/27”, {st_mode=S_IFDIR|0755, st_size=4096, …}, 0) = 0
— SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24122, si_uid=1000, si_status=0, si_utime=2, si_stime=1} —
newfstatat(AT_FDCWD, “/usr/local/sbin/git”, 0xc4205b2928, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/local/bin/git”, 0xc4205b29f8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/sbin/git”, 0xc4205b2ac8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/bin/git”, {st_mode=S_IFREG|0755, st_size=2231024, …}, 0) = 0
openat(AT_FDCWD, “/dev/null”, O_RDONLY|O_CLOEXEC) = 11
newfstatat(AT_FDCWD, “data/tmp/local-repo/27”, {st_mode=S_IFDIR|0755, st_size=4096, …}, 0) = 0
— SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24130, si_uid=1000, si_status=0, si_utime=2, si_stime=0} —
newfstatat(AT_FDCWD, “/usr/local/sbin/git”, 0xc4201dced8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/local/bin/git”, 0xc420182ac8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/sbin/git”, 0xc420182d38, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, “/usr/bin/git”, {st_mode=S_IFREG|0755, st_size=2231024, …}, 0) = 0
openat(AT_FDCWD, “/dev/null”, O_RDONLY|O_CLOEXEC) = 11
newfstatat(AT_FDCWD, “data/tmp/local-repo/27”, {st_mode=S_IFDIR|0755, st_size=4096, …}, 0) = 0
— SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24131, si_uid=1000, si_status=0, si_utime=0, si_stime=0} —


#5

500 应该是这个问题 https://github.com/gogits/gogs/issues/5138

再问一下 把APP_DATA_PATH 放到 /dev/shm/ 会不会有什么风险? 看了下好像PR后tmp也被清除了


#6

你这样设置的目的是什么。。崩溃给出go的崩溃日志,其它的一概不认

这个你可以试一下 master 分支,应该已经修复了。


#7

目的是PR合并的时候 差异太大会导致显示太多内容卡死
好像也没有分页 想少显示一点 或者可以自己展开
Body seems unclear, is it a complete sentence?


#8

那 1 也太少了。。。是只有设置为 1 的时候才会崩溃吗?我需要程序自己给出的崩溃日志