Bug 168685 - failure to bind socket acceptor in Acceptor::run() results in busy loop with 100% cpu usage
Summary: failure to bind socket acceptor in Acceptor::run() results in busy loop with...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
4.1 all versions
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-04 02:40 UTC by charkins
Modified: 2026-01-27 15:16 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description charkins 2025-10-04 02:40:27 UTC
Description:
Acceptor::run() wraps its body in a for(;;) loop. For a socket acceptor, the first line below will trigger an attempt to bind to the ip/port specified in the connection string. The next line checks to see if a valid connection was returned, if not, it breaks out of the for loop:

            // accept connection
            Reference< XConnection > rConnection = m_rAcceptor->accept( m_aConnectString );
            // if we return without a valid connection we must assume that the acceptor
            // is destructed so we break out of the run method terminating the thread
            if (! rConnection.is()) break;

If the socket acceptor fails to bind for some reason, an exception is thrown, so the break is not executed. Instead the catch block just warns of the error then immediately loops:

        } catch (const Exception&) {
            TOOLS_WARN_EXCEPTION("desktop.offacc", "");
            // connection failed...
            // something went wrong during connection setup.
            // just wait for a new connection to accept
        }

There are lots of simple ways to reproduce, including providing an invalid hostname, a hostname/ip that is not local to the machine, a privileged port, a port that is already is use, etc. This was discovered because accept was configured for "localhost" via ooSetupConnectionURL in registrymodifications.xcu and via --accept with "127.0.0.1". One would succeed and bind to the port, the other would fail to bind because the port was in use, triggering the busy loop.

Steps to Reproduce:
Launch soffice with argument: --accept='socket,host=1.1.1.1,port=8100;urp;'


Actual Results:
It will attempt and fail to bind to 1.1.1.1, triggering an exception which is logged, then repeat in a busy loop. This causes the thread to use ~100% CPU.

Expected Results:
Failure to bind should break out of the Acceptor::run().


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Change submitted: https://gerrit.libreoffice.org/c/core/+/191842
Comment 1 Werner Tietz 2025-10-04 12:49:26 UTC
Hallo
>> whois 1.1.1.1

```
inetnum:        1.1.1.0 - 1.1.1.255
netname:        APNIC-LABS
descr:          APNIC and Cloudflare DNS Resolver project
descr:          Routed globally by AS13335/Cloudflare
descr:          Research prefix for APNIC Labs
country:        AU
org:            ORG-ARAD1-AP
admin-c:        AIC3-AP
tech-c:         AIC3-AP
abuse-c:        AA1412-AP
status:         ASSIGNED PORTABLE
remarks:        ---------------
remarks:        All Cloudflare abuse reporting can be done via
remarks:        resolver-abuse@cloudflare.com
remarks:        ---------------
mnt-by:         APNIC-HM
mnt-routes:     MAINT-APNICRANDNET
mnt-irt:        IRT-APNICRANDNET-AU
last-modified:  2023-04-26T22:57:58Z
mnt-lower:      MAINT-APNICRANDNET
source:         APNIC

irt:            IRT-APNICRANDNET-AU
address:        PO Box 3646
address:        South Brisbane, QLD 4101
address:        Australia
e-mail:         helpdesk@apnic.net
abuse-mailbox:  helpdesk@apnic.net
admin-c:        AR302-AP
tech-c:         AR302-AP
auth:           # Filtered
remarks:        helpdesk@apnic.net was validated on 2021-02-09
mnt-by:         MAINT-APNICRANDNET
last-modified:  2025-09-03T02:28:14Z
source:         APNIC

organisation:   ORG-ARAD1-AP
org-name:       APNIC Research and Development
org-type:       LIR
country:        AU
address:        6 Cordelia St
phone:          +61-7-38583100
fax-no:         +61-7-38583199
e-mail:         helpdesk@apnic.net
mnt-ref:        APNIC-HM
mnt-by:         APNIC-HM
last-modified:  2023-09-05T02:15:19Z
source:         APNIC

role:           ABUSE APNICRANDNETAU
country:        ZZ
address:        PO Box 3646
address:        South Brisbane, QLD 4101
address:        Australia
phone:          +000000000
e-mail:         helpdesk@apnic.net
admin-c:        AR302-AP
tech-c:         AR302-AP
nic-hdl:        AA1412-AP
remarks:        Generated from irt object IRT-APNICRANDNET-AU
remarks:        helpdesk@apnic.net was validated on 2021-02-09
abuse-mailbox:  helpdesk@apnic.net
mnt-by:         APNIC-ABUSE
last-modified:  2025-05-28T03:31:35Z
source:         APNIC

role:           APNICRANDNET Infrastructure Contact
address:        6 Cordelia St
                South Brisbane
                QLD 4101
country:        AU
phone:          +61 7 3858 3100
e-mail:         research@apnic.net
admin-c:        AIC3-AP
tech-c:         AIC3-AP
nic-hdl:        AIC3-AP
mnt-by:         MAINT-APNICRANDNET
last-modified:  2024-07-18T04:37:37Z
source:         APNIC

% Information related to '1.1.1.0/24AS13335'

route:          1.1.1.0/24
origin:         AS13335
descr:          APNIC Research and Development
                6 Cordelia St
mnt-by:         MAINT-APNICRANDNET
last-modified:  2023-04-26T02:42:44Z
source:         APNIC

```

???
Comment 2 charkins 2025-10-04 13:19:33 UTC
1.1.1.1 is an easy example to demonstrate the bug because it causes the socket bind to fail.

A more realistic example would be '127.0.0.1:8100' when that port is already in use. This was discovered because some users had ooSetupConnectionURL set to localhost:8100 and libreoffice was launched with --accept and 127.0.0.1:8100. This caused libreoffice to try to bind to both localhost:8100 and 127.0.0.1:8100, one of which would fail because the port was already in use, triggering the busy loop.

It could also be triggered with a typo or accidental use of privileged port (<1024). For example:
- soffice.bin --accept='socket,host=l=127.0.01,port=8100;urp;'
- soffice.bin --accept='socket,host=l=127.0.0.1,port=81;urp;'
Comment 3 Buovjaga 2026-01-27 13:25:44 UTC
(In reply to charkins from comment #0)
> Change submitted: https://gerrit.libreoffice.org/c/core/+/191842

I see the change was merged quite soon after submitting and I get any issue with the command. Feel free to close this report as resolved fixed.
Comment 4 charkins 2026-01-27 15:16:50 UTC
Fix was merged and released in at least v26.2.0.1. Thanks!