Skip to content

[Bug] netdev: ping 命令在未注册网卡环境下空指针崩溃 #11744

Description

@Huoyanlifusu

RT-Thread Version

master @ 6ea6827(2026-08-21)

Affected area

Networking

Hardware/BSP vendor

Not applicable / Other

Architecture

ARM / AArch64

Board and hardware details

QEMU vexpress-a9(bsp/qemu-vexpress-a9,未配置任何网卡驱动)

Develop Toolchain

GCC

Describe the bug

复现步骤

  1. bsp/qemu-vexpress-a9 配置开启 RT_USING_NETDEVNETDEV_USING_PING 随之启用),不开 RT_USING_LWIP(无网卡环境);
  2. scons 编译后 ./qemu-nographic.sh 启动;
  3. msh 中执行 ping 1.2.3.4

实际行为

系统 data abort 崩溃:

msh />ping 1.2.3.4
backtrace:
please use: addr2line -e rtthread.elf -a -f 6004398c
 60073194 6003b378 6003b83c 600673d0 60067478 6006bc60
data abort:Execption:
r00:0x600b9854 r01:0x000000ff r02:0x00000004 r03:0x00000004
pc :0x60043994
...
(0) assertion failed at function:rt_hw_cpu_shutdown, line number:85

addr2line 解析崩溃链路:

netdev_ping        netdev.c:1437
→ netdev_cmd_ping  netdev.c:1346   ← rt_kprintf("...default netdev %s.\n", netdev->name)
→ rt_kprintf       kservice.c:410
→ rt_vsnprintf     rt_vsnprintf_tiny.c:454  ← 此处解引用 NULL

期望行为

友好提示(如 ping: no network interface device available)并返回,而非崩溃。

Other additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions