Skip to content

Firewall hangs or crashes Jamlus #3776

Open

Description

@ann0see

Describe the bug

Clicking Connect while Ethernet is active and the macOS Application Firewall is enabled causes either an immediate crash (SIGPIPE, exit code 141) or a permanent hang. WiFi is not affected.

To Reproduce

  1. Plug in Ethernet (both Ethernet and WiFi active, default route via en0)
  2. Enable the macOS Application Firewall via gui: or probably sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
  3. Launch Jamulus and click Connect
  4. The app either crashes immediately or hangs with no response from the server

Workaround: Unplug Ethernet, disable the firewall, or add Jamulus to the firewall allow list.

Expected behavior

Connect works regardless of which network interface is used and whether the firewall is enabled. If the server is unreachable, show an error instead of crashing or hanging.

Crash report (before fix)

frame #0: __sendto                          (libsystem_kernel.dylib)
frame #1: Jamulus CSocket::Send             (socket.cpp)
frame #2: Jamulus                           (ConnLessProtocol / Protocol layer)
frame #3: Jamulus                           (Protocol layer)
frame #4: QtCore QSocketNotifier            (via Qt event loop)
frame #5-8: Jamulus                         (various)
frame #9: QObject::event
frame #10: QWidget::event
frame #11-12: QtWidgets QApplication
frame #13: QtCore QCoreApplication::sendEvent
frame #14: QtCore QCoreApplicationPrivate::sendPostedEvents

Root cause (likely; AI assisted)

The macOS Application Firewall silently drops Jamulus's outgoing UDP packets when traffic originates from the Ethernet interface. WiFi works because it was already trusted (?). Before the fix, the dropped packets caused a SIGPIPE (no receiver). After the SO_NOSIGPIPE fix (handling macOS like iOS), it became a hang since the connection attempt never completes and IsConnected() stays false.

Operating system

macOS 26.5.2, Apple Silicon (arm64), Xcode 26.6

AI proposed Fix

Two changes were needed of which the first one I am not sure about:

1. SO_NOSIGPIPE (src/socket.cpp):

// Before:
#ifdef Q_OS_IOS
    int valueone = 1;
    setsockopt ( UdpSocket, SOL_SOCKET, SO_NOSIGPIPE, &valueone, sizeof ( valueone ) );
#endif

// After:
#if defined( Q_OS_IOS ) || defined( Q_OS_MACOS )
    int valueone = 1;
    setsockopt ( UdpSocket, SOL_SOCKET, SO_NOSIGPIPE, &valueone, sizeof ( valueone ) );
#endif

This prevents a SIGPIPE crash but doesn't fix the hang.

2. Connection timeout (src/clientdlg.cpp):

Added a 5-second TimerConnectTimeout in CClientDlg. If IsConnected() is still false when it fires, the app shows a warning about the firewall and disconnects. The timer is stopped on successful connection (OnConClientListMesReceived) or on manual disconnect.

To be discussed.

Additional context

/

Activity

  1. mcfnord commented on Jul 19, 2026

    @mcfnord
    Contributor

    Root cause (static analysis, per the request in #3804). The code confirms both halves of the report, and the proposed two-part fix matches what the code is actually missing.

    The crash. SO_NOSIGPIPE is set only under #ifdef Q_OS_IOS, at both socket-creation sites (socket.cpp#L240-L244 for IPv4, #L307-L311 for IPv6). The comment on those lines — "ignore the broken pipe signal to avoid crash (iOS)" — shows this exact crash was already diagnosed and fixed once on iOS; macOS was simply never included in the guard, and SO_NOSIGPIPE exists on both (it's a Darwin socket option, not an iOS one). When the Application Firewall's socket filter kills the UDP flow, sendto() fails with EPIPE and the default SIGPIPE disposition terminates the process — consistent with the reported exit code 141 (128 + 13 = SIGPIPE) and the __sendto ← CSocket::Send crash frame. So fix 1 (extend the guard to Q_OS_MACOS) addresses the real root cause; it's the same bug the iOS ifdef already fixed.

    The hang after fix 1. Confirmed: there is no connect-attempt timeout anywhere in the client. CChannel's timeout machinery only runs once a connection is established; a connect whose packets are silently dropped never reaches that state, so nothing ever fires and the GUI stays in "trying to connect" indefinitely. A connect timeout like fix 2 is therefore a genuinely missing feature, not a regression — though CClient (which owns the connection lifecycle) may be a cleaner home for it than CClientDlg, so headless clients get the same behavior.

    One caveat for the record: this analysis was not reproduced on macOS hardware; the EPIPE-from-firewall mechanism rests on the crash report in the issue, with which the code evidence is fully consistent.

  2. added this to the Release 4.1.0 milestone on Jul 20, 2026
  3. pljones commented on Jul 20, 2026

    @pljones
    Collaborator

    the GUI stays in "trying to connect" indefinitely

    It'll do this for a variety of reasons, including a server being full. Definitely a separate issue from this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status
      Triage

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions