donglei2288 2019-01-15 01:02
浏览 71

访问安装的目录时遇到分段违规

segmentation violation code=0x1 error when accessing mounted network share

Ubuntu server running a golang applicaiton (PwnDelorian) crashes. Checked permissions of directory, everything seems fine there.

        fileList := []FileStruct{}
        err := filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
                fileList = append(fileList, FileStruct{f.Name(), path})
                return nil
        })
        if err != nil {
                return nil, err
        }
        return fileList, nil
}

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

>goroutine 1 [running]:
main.getAllFilesInDirectory.func1(0xc42031d950, 0x49, 0x0, 0x0, 0x71ea20, 0xc4202ba990, 0x0, 0x0)
        /home/jim/go/src/PwnDelorean/filesystem.go:42 +0x2f
path/filepath.walk(0xc42030fa80, 0x3c, 0x721ec0, 0xc420357930, 0xc42009b730, 0x0, 0x0)
        /usr/lib/go-1.10/src/path/filepath/path.go:377 +0x20d
path/filepath.walk(0xc42033eab0, 0x24, 0x721ec0, 0xc420356c30, 0xc42009b730, 0x0, 0x0)
        /usr/lib/go-1.10/src/path/filepath/path.go:381 +0x2c2
path/filepath.walk(0xc420313260, 0x16, 0x721ec0, 0xc420356820, 0xc42009b730, 0x0, 0x0)
        /usr/lib/go-1.10/src/path/filepath/path.go:381 +0x2c2
path/filepath.walk(0x7ffd2448320a, 0x11, 0x721ec0, 0xc4200a1d40, 0xc42009b730, 0x0, 0x10)
        /usr/lib/go-1.10/src/path/filepath/path.go:381 +0x2c2
path/filepath.Walk(0x7ffd2448320a, 0x11, 0xc42009b730, 0x0, 0x4982c4)
        /usr/lib/go-1.10/src/path/filepath/path.go:403 +0x106
main.getAllFilesInDirectory(0x7ffd2448320a, 0x11, 0x11, 0x0, 0xc4200a1ba0, 0xc42006bdf0, 0x497b5d)
        /home/jim/go/src/PwnDelorean/filesystem.go:41 +0xc4
main.startFileSystemScan()
        /home/jim/go/src/PwnDelorean/filesystem.go:129 +0x4e
main.main()
        /home/jim/go/src/PwnDelorean/main.go:136 +0x91




  • 写回答

1条回答 默认 最新

  • dspvin19712 2019-01-15 02:08
    关注
    panic: runtime error: invalid memory address or nil pointer dereference
    

    Start with the documentation:

    Package filepath

    import "path/filepath"

    type WalkFunc

    In the case of an error, the info argument will be nil.

    type WalkFunc func(path string, info os.FileInfo, err error) error
    
    评论

报告相同问题?

悬赏问题

  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接