Skip to content

[BUG] assert in semaphore/sem_wait.c due to netdev_carrier_on called in interrupt context. #18421

@masc2008

Description

@masc2008

Description / Steps to reproduce the issue

DEBUGASSERT(sem != NULL && up_interrupt_context() == false).

This will be triggered with with commit: a756767

the flow is like this: in drivers/usbdev/rndis.c, usbclass_setconfig is called in interrrupt context, then it will call if (priv->netdev.d_ifup(&priv->netdev) == OK), then do netdev_carrier_on, then netlink_device_notify, then netlink_add_broadcast, then net_lock.

I picked this commit while kept other components with a older nuttx version, while the major flow is still same, I believe it's same situation with everything is updated to latest.

[10:16:34.838][ 251.083700] [ 0] [apc1] dump_assert_info: Current Version: NuttX BES NuttX EVB 12.6.0 a76e463129-dirty Feb 21 2026 10:10:04 arm
[10:16:34.838][ 251.083700] [ 0] [apc1] dump_assert_info: Assertion failed : at file: semaphore/sem_wait.c:252 task: Idle_Task process: Kernel 0x1a8e58b9
[10

[10:16:34.946][ 251.100100] [ 0] [apc1] sched_dumpstack: backtrace:
[10:16:34.946][ 251.100100] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8fb03e>] sched_dumpstack+0x1d/0x70
[10:16:34.946][ 251.100600] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1aa016ee>] _start+0x5/0xc
[10:16:34.946][ 251.100900] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8f0ffe>] syslog_default_flush+0x1/0xa
[10:16:34.947][ 251.101200] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8f10fc>] syslog_flush+0x17/0x28
[10:16:34.947][ 251.101600] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8e5d02>] stack_dump+0xa1/0xb0
[10:16:34.947][ 251.101900] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1aa016ee>] _start+0x5/0xc
[10:16:34.947][ 251.102200] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8e42ba>] system_subsys_start+0x85/0xa0
[10:16:34.947][ 251.102500] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8e6074>] _assert+0x19f/0x2bc
[10:16:34.947][ 251.102900] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a905e14>] bes_oneshot_ticks_current+0x13/0x20
[10:16:34.947][ 251.103300] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8f29e0>] cdcacm_write+0x7/0xd4
[10:16:34.955][ 251.103600] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8f55e0>] __assert+0x3/0xc
[10:16:34.961][ 251.103900] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8e8768>] nxsem_wait+0xb/0x118
[10:16:34.967][ 251.104200] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8f6e90>] nxmutex_lock+0x1f/0x38
[10:16:34.974][ 251.104500] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8f7008>] nxrmutex_lock+0xb/0x34
[10:16:34.979][ 251.104800] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a9e09e6>] netlink_add_broadcast+0x19/0x90
[10:16:34.986][ 251.105200] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a9e10a4>] netlink_device_notify+0x1b/0x34
[10:16:34.993][ 251.105700] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a9079cc>] bes_req_dispatch.constprop.0+0x1b/0x38
[10:16:34.999][ 251.106100] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a907a60>] bes_setcfg_handler+0x1/0xe
[10:16:35.006][ 251.106400] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8df0e0>] hal_usb_irq_handler+0xa5f/0xca8
[10:16:35.012][ 251.106800] [ 0] [apc1] sched_dumpstack: [ 0] [<0xc0a14>] up_irq_handler+0x3/0xa
[10:16:35.020][ 251.107100] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a908a7c>] arm_doirq+0x53/0x68
[10:16:35.025][ 251.107400] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a904bfe>] exception_common+0x65/0x9c
[10:16:35.029][ 251.107800] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8e5a3c>] nx_start+0x183/0x1c4
[10:16:35.030][ 251.108100] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1aa016ee>] _start+0x5/0xc
[10:16:35.030][ 251.108400] [ 0] [apc1] sched_dumpstack: [ 0] [<0x1a8e42ba>] system_subsys_start+0x85/

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

ubuntu 2204

NuttX Version

master

Issue Architecture

[Arch: all]

Issue Area

[Area: Drivers]

Host information

this is a general issue with rndis.c,

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: allIssues that apply to all architecturesArea: DriversDrivers issuesOS: LinuxIssues related to Linux (building system, etc)Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions