uWebSockets icon indicating copy to clipboard operation
uWebSockets copied to clipboard

Strict Weak Ordering Check failing when adding an http handler

Open FabianHummel opened this issue 1 year ago • 2 comments

The sort method fails the "__check_strict_weak_ordering_sorted" check when adding an entry to the handler list during debug mode.

https://github.com/uNetworking/uWebSockets/blob/600e7fe0faf74fb54722720a6d2e3f545d99f548/src/HttpRouter.h#L304-L317

Specifically, this abort is triggered: https://github.com/llvm/llvm-project/blob/77f8297c6fdaa62121ddb108043dcaad5c45c7ad/libcxx/include/__debug_utils/strict_weak_ordering_check.h#L49

auto app = uWS::App();

app.get("/", [](auto *res, auto *req) {
    res ->writeStatus("200 OK");
});

https://en.cppreference.com/w/cpp/named_req/Compare

Establishes strict weak ordering relation with the following properties:

  • For all a, comp(a, a) == false.

macOS Sonoma 14.6.1 Apple clang version 16.0.0 (clang-1600.0.26.3) Xcode 16.0 Build version 16A242d

FabianHummel avatar Oct 13 '24 19:10 FabianHummel

Aha, ok. But this only happens if you build the binary yourself?

uNetworkingAB avatar Oct 13 '24 20:10 uNetworkingAB

The strict weak ordering is a relatively new addition to the standard library and could be the cause why I did not get this error some longer time ago.

I use uWebSocket in a shared library and link it together with swiftui frontend code all within xcode. Internally I think it uses gnu g++23.

I was able to get around this issue by setting the compiler definition "_LIBCPP_HARDENING_MODE" to "_LIBCPP_HARDENING_MODE_EXTENSIVE" or, in fact, to any mode other than "_LIBCPP_HARDENING_MODE_DEBUG" as this generates the checks for strict weak ordering

FabianHummel avatar Oct 13 '24 20:10 FabianHummel

Encountering the same issue, is there going to be any ETA on a fix for this?

brianferri avatar Dec 03 '24 21:12 brianferri

I can't reproduce it:

CXXFLAGS="-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" make

produces:

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/EchoBody.cpp uSockets/*.o -lz -o EchoBody

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/HelloWorldThreaded.cpp uSockets/*.o -lz -o HelloWorldThreaded

In file included from examples/HelloWorldThreaded.cpp:2:

*src/LocalCluster.h:22:42: **warning: *unused variable 'roundRobin' [-Wunused-variable]

22 | static std::atomic roundRobin = 0; // atomic fetch_add

  | *                                         ^~~~~~~~~~*

1 warning generated.

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/Http3Server.cpp uSockets/*.o -lz -o Http3Server

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/Broadcast.cpp uSockets/*.o -lz -o Broadcast

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/HelloWorld.cpp uSockets/*.o -lz -o HelloWorld

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/Crc32.cpp uSockets/*.o -lz -o Crc32

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/ServerName.cpp uSockets/*.o -lz -o ServerName

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/EchoServer.cpp uSockets/*.o -lz -o EchoServer

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/BroadcastingEchoServer.cpp uSockets/*.o -lz -o BroadcastingEchoServer

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/UpgradeSync.cpp uSockets/*.o -lz -o UpgradeSync

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/UpgradeAsync.cpp uSockets/*.o -lz -o UpgradeAsync

--> g++ -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -march=native -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++20 -Isrc -IuSockets/src -flto=auto examples/ParameterRoutes.cpp uSockets/*.o -lz -o ParameterRoutes

Den tis 3 dec. 2024 kl 22:23 skrev Brian Ferri @.***>:

Encountering the same issue, is there going to be any ETA on a fix for this?

— Reply to this email directly, view it on GitHub https://github.com/uNetworking/uWebSockets/issues/1793#issuecomment-2515578228, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2NMOMMEX5RFCQFGD7NAK2L2DYOM3AVCNFSM6AAAAABP3WXYXGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJVGU3TQMRSHA . You are receiving this because you commented.Message ID: @.***>

uNetworkingAB avatar Dec 04 '24 00:12 uNetworkingAB

It is fixed now

Den tis 3 dec. 2024 kl 22:23 skrev Brian Ferri @.***>:

Encountering the same issue, is there going to be any ETA on a fix for this?

— Reply to this email directly, view it on GitHub https://github.com/uNetworking/uWebSockets/issues/1793#issuecomment-2515578228, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2NMOMMEX5RFCQFGD7NAK2L2DYOM3AVCNFSM6AAAAABP3WXYXGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJVGU3TQMRSHA . You are receiving this because you commented.Message ID: @.***>

uNetworkingAB avatar Dec 04 '24 00:12 uNetworkingAB