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
Extreme memory usage. #9
Comments
Do you have a sample of the RAR file causing the problem? |
Main cause is $block['extra_size'] having an extremely high value https://github.com/zeebinz/rarinfo/blob/master/rarinfo.php#L1277. So the while loop is iterating until it is exhausting all of the available memory. I have var_dumped the hell out of it, and $block['extra_size'] on proper RAR goes from 9 to 12 (on samples used) while on bad RARs value is sometimes even 2-3M so the $end value ($this->offset+$block['extra_size']) is very large value while loop needs to iterate on. |
I'm seeing this too, in newznab. This is with PHP 7.0.1 x64 with memory limit set to 3GB.
Given that this hasn't been updated in years doesn't give me a lot of hope for a fix. I'll try to see if I can't find a sample RAR that casues the issue. |
you trying to index boneless or something ? aka you sure this is fault of rarinfo or just rarinfo running into the fact that theres no free memory... as OOM issues have plagued newznab forever due to badly configured settings (keeping parts) / trying to index really crappy groups and with obfuscation / etc.. which have nothing to do with rarinfo directly... usual fix is to find the 'release' thats causing all the usage and just to nuke it and move along.. the two latest culprits for example are: |
I have a reproducible case. newznab (and probably other indexers as well) often download just a segment of a post and then try to identify the file contents (rarinfo and other tools are used). This particular file, for some reason, causes rarinfo to allocate memory until php terminates it. File sample: sample file link Test code:
|
what happens if you call |
If I do
Sample should work now. |
I saw earlier in the thread concern about I added an echo for some additional data to be shown to rarinfo.php: Result:
|
are you using nzedb/darrius's version? which they had to update to support php 7.x... |
I'm using whatever is packaged with newznab 0.2.3 r3505. I have been running PHP 5.5.30 (when this issue first arose as well), I just recently upgraded to PHP 7. I haven't had any other problems than this. I'll pass along the rarinfo fork info to the newznab people though. |
mind trying out darius's fork to see if it has the same issue? |
My fork is having same issues, but feel free to try it. |
I'm having trouble testing DarisIII's fork since it seems to use a different namespace. Basically I get
My ugly test code has it organized like this:
The other two 'forks' (I am pretty sure what |
You can't use my fork without composer or PSR-0 autoloader. |
I've been doing some debugging with this on the main (zeebinz) branch and the problem may be this. When the memory allocation error occurs, in In this example, when
The while loop is entered with the condition It goes into
For some reason (PHP bug?), the part in marked below keeps executing over and over:
The solution perhaps would be to check |
I've made a couple patches to check |
Thanks @LeeThompson for the sample file and digging into the code. Yes, the problem was with certain corrupt headers and variable ints, happily the fix was an easy one. |
For some reason rarinfo is using insane amounts of memory. It actually used up all free memory on my main server that has 256gb of ram. I reduced the ram usage allotment for php to 4gb to keep it from crashing the entire server but now all I see in my error log is this:
[05-Jul-2016 11:56:36 America/New_York] PHP Fatal error: Allowed memory size of 4294967296 bytes exhausted (tried to allocate 72 bytes) in /libs/zeebinz/rarinfo/rarinfo.php on line 1287 [05-Jul-2016 11:56:37 America/New_York] PHP Fatal error: Allowed memory size of 4294967296 bytes exhausted (tried to allocate 32 bytes) in zeebinz/rarinfo/rarinfo.php on line 1404
Over and over and over again, different line numbers all the time but hovering between line 1200 and 1450 or so. When this fatal error occurs it actually crashes the php-fpm thread it was running on and any other processes that were using it fail and the end-user gets a white screen for that page.
The text was updated successfully, but these errors were encountered: