Skip to content

base os: remove longstanding layering violation #75513

@cfriedt

Description

@cfriedt

Describe the bug
In the Base OS, fdtable.h introduced a layering violation (in the first (?) commit) in which the POSIX header <sys/types.h> is included and the POSIX type ssize_t is used in a way that can be described as "below the line" (the line being where the POSIX API lives in the software stack). Such a layering violation creates a dependency cycle at the API level. As noted in the original commit, the wrong types seem to be added to satisfy some need of the native_posix platform.

As part of the base OS, the layering violation spread throughout the Zephyr project into the following areas (and likely more):

  • Base OS
  • Networking
  • Filesystem
  • Modem Driversd
  • Network Drivers
  • Bluetooth simulator
  • Native drivers
  • C Library
  • C++
  • POSIX API

Aside from extensive manual testing with twister and CI not catching a strange set of bugs, this layering violation was also the root cause for #75205 (as demonstrated by #75348 archived here with testing details here).

Please also mention any information which could help others to understand
the problem you're facing:

  • What target platform are you using? all
  • What have you tried to diagnose or workaround this issue? found the root cause
  • Is this a regression? Technically no, it was just always broken f484bba

To Reproduce
Steps to reproduce the behavior:

  1. See multipe tests/posix & tests/lib/c_lib/thrd build failures due to missing time.h definitions #75205

Expected behavior
Developers and reviewers adding code which does not introduce dependency cycles and layering violations.

Impact
This bug caused planned features to be removed from the v3.7.0 release. If it is not fixed, it will mean that the next LTS release cycle will still be quite full of these layering violations and will prevent further bugfixes from being backported to all of the aforementioned areas.

Logs and console output

Environment (please complete the following information):

  • OS: any
  • Toolchain (e.g Zephyr SDK, ...): all
  • Commit SHA or Version used: c9708ff

Additional context

The simpler workaround was deemed to simple. So maintainers asked for the more complicated fix. There is a PR linked to demonstrate the more complicated fix.

This bug is blocking the following (TSC-approved) features from being re-added to v3.7.0.

POSIX_FD_MGMT

POSIX_DEVICE_IO

This bug is blocking other architectural fixes that have plagued Zephyr for multiple (actually all) LTS release cycles already

This bug is also blocking numerous the stability improvements mentioned here.

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions