Skip to content

FreeBSD 编译/运行失败 Segmentation fault (core dumped) #163

Closed
@juzeon

Description

@juzeon

你操作了什么?

编译

发生了什么?

编译失败/编译成功但core dumped

本应该怎么样?

正常运行

chsrc 版本

源码 536c69d

你使用的是哪个操作系统?

FreeBSD

OS 版本 / OS 发行版

见下文系统信息

Log 输出

# 系统信息
root@freebsd:~ # cc -v
FreeBSD clang version 18.1.6 (https://github.com/llvm/llvm-project.git llvmorg-18.1.6-0-g1118c2e05e67)
Target: x86_64-unknown-freebsd14.2
Thread model: posix
InstalledDir: /usr/bin
root@freebsd:~/chsrc # cat /etc/os-release
NAME=FreeBSD
VERSION="14.2-RELEASE"
VERSION_ID="14.2"
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 14.2-RELEASE"
CPE_NAME="cpe:/o:freebsd:freebsd:14.2"
HOME_URL="https://FreeBSD.org/"
BUG_REPORT_URL="https://bugs.FreeBSD.org/"
root@freebsd:~/chsrc # uname -ra
FreeBSD freebsd 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64
# 直接从 https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/14.2/FreeBSD-14.2-RELEASE-amd64-disc1.iso 下载的


# 第一次尝试,按照README
root@freebsd:~/chsrc # cc -Iinclude src/chsrc-main.c -o chsrc
In file included from src/chsrc-main.c:35:
src/framework/core.c:17:10: fatal error: 'xy.h' file not found
   17 | #include "xy.h"
      |          ^~~~~~
1 error generated.


# 第二次尝试,增加-Ilib参数
root@freebsd:~/chsrc # cc -g -Iinclude -Ilib src/chsrc-main.c -o chsrc
In file included from src/chsrc-main.c:35:
In file included from src/framework/core.c:17:
lib/xy.h:646:1: warning: non-void function does not return a value [-Wreturn-type]
  646 | }
      | ^
1 warning generated.
root@freebsd:~/chsrc # chmod +x chsrc
root@freebsd:~/chsrc # ./chsrc set freebsd first
Segmentation fault (core dumped)

# 第三次,尝试gdb
root@freebsd:~/chsrc # cc -g -Iinclude -Ilib src/chsrc-main.c -o chsrc
In file included from src/chsrc-main.c:35:
In file included from src/framework/core.c:17:
lib/xy.h:646:1: warning: non-void function does not return a value [-Wreturn-type]
  646 | }
      | ^
1 warning generated.
root@freebsd:~/chsrc # chmod +x chsrc
root@freebsd:~/chsrc # gdb ./chsrc
GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD]
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd14.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./chsrc...
(gdb) run set freebsd first
Starting program: /root/chsrc/chsrc set freebsd first
[Detaching after vfork from child process 1665]

Program received signal SIGSEGV, Segmentation fault.
Address not mapped to object.
0x00000008003de9e3 in strtol_l () from /lib/libc.so.7
(gdb) bt
#0  0x00000008003de9e3 in strtol_l () from /lib/libc.so.7
#1  0x0000000000213c57 in chsrc_ensure_root () at src/framework/core.c:1028
#2  0x000000000021fa61 in os_freebsd_setsrc (option=0x800808008 "first") at src/recipe/os/BSD/FreeBSD.c:40
#3  0x000000000022368e in get_target (input=0x7fffffffedde "freebsd", code=TargetOp_Set_Source,
    option=0x800808008 "first") at src/chsrc-main.c:532
#4  0x000000000022446e in main (argc=3, argv=0x7fffffffeab0) at src/chsrc-main.c:799

防止重复问题

  • 我已在项目的 GitHub 和 Gitee 两个仓库分别搜索过类似的 issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions