Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OOM Issue (StringHelper.php:211) on PHP 8.2 / TS 3.13 #216

Open
M4LuZ opened this issue Apr 9, 2024 · 3 comments
Open

OOM Issue (StringHelper.php:211) on PHP 8.2 / TS 3.13 #216

M4LuZ opened this issue Apr 9, 2024 · 3 comments

Comments

@M4LuZ
Copy link

M4LuZ commented Apr 9, 2024

Hi y'all,

I'm currently working on a refresh of the integration of ts3phpframework into the LanSuite Lanparty CMS .
I'm facing an apparent regression between 1.1.35 and 1.2.1 causing an out-of-memory error ultimately thrown in StringHelper.php Line 211

Story so far

  • I've upgraded our composer dependency to ^1.2, thus ending on 1.2.1 as version used
  • Fixed some obvious issues due to changes in the meantime
  • set up a fresh TS, used pre-created account serveradmin for the query connection
  • Did a test call based on the example in README.md
  • When executing the initial object creation via $TS3PHPFramework->factory($uri); I ran into out-of-memory errors
  • To see if this is an issue already fixed I switched to dev-master (!)
  • After fixing namespacing and URI build I was able to get the example working fine. So URI, credentials and privileges appear to be OK
  • I've noticed then that dev-master is apparently outdated after renaming, on state of 1.1.35 and as far as text goes not really compatible with PHP 8.2.
  • Switching back to 1.2.1 has the issue reappearing immediately, same on dev-dev (duh!)

I saw that this issue was apparently already noticed and supposed to be fixed in #195 but somehow this appears not to be the case?
So would be greatly appreciated to get some feedback on that.

Environment

  • PHP 8.2.12
  • Teamspeak 3.13.7 Windows (x64)
@M4LuZ
Copy link
Author

M4LuZ commented Apr 10, 2024

Did a bit of tracing on dev-dev and it turns out that the memory leak is in the Transport destructor.

Apparently while waitForReadyRead in Transport.php is supposed to immediately return when disconnected or in blocking mode it goes through the do {...} while(@stream_select(...)) loop indefinitely.
Adding blocking=0 to the query string appears to break the loop, timeout does not.

2024-04-10 21_58_14-WinCacheGrind -  C__xampp_htdocs_lansuite_index php (cachegrind out 12668)

@toster234
Copy link

I moved $this->disconnect(); in Transport.php destructor and the issue seems to be fixed?

    public function __destruct()
    {
+       $this->disconnect();
        if ($this->adapter instanceof Adapter) {
            $this->adapter->__destruct();
        }
-
-        $this->disconnect();
    }

@M4LuZ
Copy link
Author

M4LuZ commented Jul 10, 2024

Hi @toster234 ,

sorry for the late reply.
Can confirm that this solves the issue for me.
A quick check with the text viewer worked OK (the other two HTML / JSON appear to be broken and are the next ticket to be raised).

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

No branches or pull requests

2 participants