Skip to content

Fix missing return in test function causing SIGILL with GCC 14#330

Merged
yxieca merged 2 commits intosonic-net:masterfrom
yxieca:fix/test-missing-return
Apr 3, 2026
Merged

Fix missing return in test function causing SIGILL with GCC 14#330
yxieca merged 2 commits intosonic-net:masterfrom
yxieca:fix/test-missing-return

Conversation

@yxieca
Copy link
Copy Markdown
Contributor

@yxieca yxieca commented Apr 3, 2026

Description

MuxManagerTest::setUseWellKnownMacActiveActive() is declared as returning bool but has no return statement. This is undefined behavior in C++.

  • GCC 13 (bookworm): Silently ignores the missing return
  • GCC 14 (trixie): Inserts ud2 (intentional illegal instruction) to trap the UB

This causes MuxManagerTest.ServerMacActiveActiveBeforeLinkProberInit to crash with SIGILL (exit code 132) when linkmgrd is built in a trixie environment.

Root Cause

// test/MuxManagerTest.cpp:118
bool MuxManagerTest::setUseWellKnownMacActiveActive(bool use)
{
    mMuxManagerPtr->setUseWellKnownMacActiveActive(use);
    // No return statement — UB!
}

The underlying MuxManager::setUseWellKnownMacActiveActive() returns void, so the test wrapper should too.

Fix

Change return type from bool to void in both the declaration (.h) and definition (.cpp).

How I tested

  • Built linkmgrd test binary with -g -O0 in trixie slave container
  • Ran under GDB: crash at ud2 instruction at function epilogue
  • After fix: function no longer has missing return UB

setUseWellKnownMacActiveActive() is declared as returning bool but has
no return statement. This is undefined behavior in C++ that GCC 13
(bookworm) silently ignores but GCC 14 (trixie) traps with ud2,
causing SIGILL in MuxManagerTest.ServerMacActiveActiveBeforeLinkProberInit.

Change return type to void to match the underlying MuxManager method.

Signed-off-by: Ying Xie <[email protected]>
Signed-off-by: Ying Xie <[email protected]>
@yxieca yxieca requested review from lolyu and zjswhhh as code owners April 3, 2026 07:00
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

yxieca added a commit to yxieca/sonic-buildimage that referenced this pull request Apr 3, 2026
Migrate the mux (linkmgrd) docker container from Debian bookworm to
trixie, aligning it with other containers already on trixie.

Changes:
- Update Dockerfile.j2 base image from bookworm to trixie
- Update docker-mux.mk references from BOOKWORM to TRIXIE

Depends on: sonic-net/sonic-linkmgrd#330
(fixes SIGILL in unit tests caused by GCC 14 catching missing return UB)

Signed-off-by: Ying Xie <[email protected]>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@yxieca yxieca merged commit 5c657f0 into sonic-net:master Apr 3, 2026
10 checks passed
@yxieca yxieca deleted the fix/test-missing-return branch April 3, 2026 21:53
yxieca added a commit to yxieca/sonic-buildimage that referenced this pull request Apr 3, 2026
Migrate the mux (linkmgrd) docker container from Debian bookworm to
trixie, aligning it with other containers already on trixie.

Changes:
- Update Dockerfile.j2 base image from bookworm to trixie
- Update docker-mux.mk references from BOOKWORM to TRIXIE

Depends on: sonic-net/sonic-linkmgrd#330
(fixes SIGILL in unit tests caused by GCC 14 catching missing return UB)

Signed-off-by: Ying Xie <[email protected]>
yxieca added a commit to yxieca/sonic-buildimage that referenced this pull request Apr 4, 2026
Migrate the mux (linkmgrd) docker container from Debian bookworm to
trixie, aligning it with other containers already on trixie.

Changes:
- Update Dockerfile.j2 base image from bookworm to trixie
- Update docker-mux.mk references from BOOKWORM to TRIXIE

Depends on: sonic-net/sonic-linkmgrd#330
(fixes SIGILL in unit tests caused by GCC 14 catching missing return UB)

Signed-off-by: Ying Xie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants