FXServer Crash: fd_to_send >= 0 Assertion Failure with Thread Hitches

Bug Information

Client Version: FXServer (production) FXServer Version: [Latest stable - exact version from crash dump: c7b7731d-21cb-417d-96015995-d9d3b651] Operating System: Linux (Rocky Linux 9) Category: Server crash - File descriptor/Network handling

Expected Behavior

  • Player save operations should complete successfully
  • Server should remain stable during normal gameplay
  • Network operations should not exhaust file descriptors

Actual Behavior

  • Server crashes immediately after player save operations
  • Assertion failure in libuv network handling code
  • Multiple thread performance hitches before crash
  • Complete server termination requiring restart

Crash Details

Error Message

[      script:qb-core] [qb-core:LOG] Gabriel PLAYER SAVED!
Assertion failed: fd_to_send >= 0 (../deps/uv/src/unix/stream.c: uv__try_write: 791)
[ citizen-server-impl] network thread hitch warning: timer interval of 324 milliseconds
[ citizen-server-impl] server thread hitch warning: timer interval of 341 milliseconds
[ citizen-server-impl] sync thread hitch warning: timer interval of 323 milliseconds
=================================================================
FXServer crashed.
A dump can be found at /home/evergreen/EverGreen/alpine/opt/cfx-server/crashes/c7b7731d-21cb-417d-96015995-d9d3b651.dmp.
Failed to automatically report the crash. Please submit the crash dump to the project developers.
=================================================================
Aborted (core dumped)

Technical Analysis

  • Root Cause: File descriptor exhaustion leading to invalid fd_to_send value
  • Trigger: Player save operations in QB-Core framework
  • Secondary Effects: Network and server thread performance degradation (300ms+ hitches)
  • Location: libuv stream handling code (../deps/uv/src/unix/stream.c:791)

Reproducible Steps

  1. Set up FXServer with QB-Core framework
  2. Configure server with default file descriptor limits (1024)
  3. Load multiple resources and connect players
  4. Trigger player save operation (disconnect/manual save)
  5. Server crashes with fd_to_send >= 0 assertion failure

Contributing Factors

System Configuration

  • File descriptor limit: 1024 (system default - too low for FiveM)
  • Resource load: High number of loaded resources
  • Database operations: Multiple concurrent MySQL connections
  • Network activity: Large LUA table transmissions

Workaround/Solution

Immediate Fix:

# Increase file descriptor limits
ulimit -n 65536

# Add to /etc/security/limits.conf:
* soft nofile 65536
* hard nofile 65536

Impact

  • Severity: Critical - Complete server crash
  • Frequency: Occurs consistently during player save operations
  • Workaround Available: Yes (increase file descriptor limits)
  • Data Loss: Potential player progress loss if save operation fails

Additional Information

Hardware: AMD Ryzen 9 7950X3D 16-Core Processor
, 128 GB RAM/CPU Network: Remote MySQL database connection Framework: QB-Core with oxmysql Players: Occurs with low player count (1-3 players)

The issue appears to be a combination of:

  1. System-level file descriptor limitations
  2. FXServer’s aggressive file descriptor usage during network operations
  3. Large data transmissions triggering the libuv assertion

Crash dump available at:
c7b7731d-21cb-417d-96015995-d9d3b651.dmp (4.7 MB)

1 Like

Any idea what is causing this or to trace it?

I have the same issue, I used your workaround and it worked, but recently some exploiters have realized they can make the FX Server hit that limit again via DDoS attacks and here we are again with the server crashing and restarting in a loop, and after a while it triggers rate limiting with the key validation system.

1 Like

Just curious, have you tried setting LimitNOFILE=65536 directly in your systemd service file instead? It’s usually a lot cleaner and more reliable than messing with limits.conf

Currently experiencing the same,

Even after setting both a systemd service limit and editing configs for them i still run into the same issue of a forever boot loop

║ STDERR║ Assertion failed: fd_to_send >= 0 (…/deps/uv/src/unix/stream.c: uv__try_write: 791)

Running on debian 13 image and am nowhere near resource limits CPU/MEM

1 Like

Same here boss

1 Like