Skip to content

HardFault in _lws_plat_service_tsi(): NULL protocols[0].callback from empty "system" vhost when all LWS_WITH_SYS_* are off #3622

Description

@aksilicon

We're hitting a HardFault on a client-only FreeRTOS build and would appreciate guidance on the correct way to handle it.

In our configuration LWS_WITH_SYS_ASYNC_DNS, LWS_WITH_SYS_NTPCLIENT, and LWS_WITH_SYS_DHCP_CLIENT are all disabled (we rely on lwIP for DNS/DHCP and have no NTP). With this setup, the internal "system" vhost in context.c is still created (the block is guarded by #if defined(LWS_WITH_NETWORK)). Since no system protocols are present, pp[0] = NULL, so the vhost ends up with count_protocols == 0 and a zeroed protocols[0] (NULL callback). As vhosts are appended and the system vhost is created first, it sits at the head of vhost_list.

_lws_plat_service_tsi() (lib/plat/freertos/freertos-service.c:91) then performs its one-time LWS_CALLBACK_GET_THREAD_ID dispatch on context->vhost_list->protocols[0].callback, which is NULL → branch to 0x00000000 → HardFault.

We notice that on 4.3.3 the same block was guarded by #if defined(LWS_WITH_SYS_ASYNC_DNS) || defined(LWS_WITH_SYS_NTPCLIENT) || defined(LWS_WITH_SYS_DHCP_CLIENT), where no empty system vhost was created and the head vhost was the user vhost (valid callback). Enabling any one SYS protocol (e.g. NTP) also masks the crash by giving protocols[0] a real callback.

Could you advise on the intended/supported way to run a client-only build with all LWS_WITH_SYS_* protocols disabled without hitting this NULL callback? Is the unconditional creation of the empty system vhost expected here, and what is the recommended configuration or handling to avoid the HardFault? Happy to provide more details, logs, or test any suggested change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions