« first day (2168 days earlier)      last day (2766 days later) » 

12:02 AM
that German explained link by @AlmaDo has been severely understarred.
 
@Sherif Basically each user-input to array conversion (where user controls keys (at large scale — I mean, you need on the order of 2^14 or such collisions to effectively induce a major slowdown) … ) is a target
 
6 mins ago, by Sherif
the lazy fix was lazy
 
Everything else is less of a target and needs to be searching quite a bit to effectively launch HashDos.
 
The correct fix would be to change PHP's hashing function so that it randomizes, like Perl did, but that's basically a nightmare.
Lazy fix prevents the direct targeting of the DoS attack though.
 
Thus, if you had a parser in userland which does YAML-to-array (or whatever shitty non-common format) … there's nothing you can do, except arbitrary limits
 
12:07 AM
Right, so let's see who actually wants to be audacious enough to attempt fixing PHP's internal hash function :)
crickets
 
@Sherif the problem is that it cannot be fixed without too much overhead
Nikita sometime proposed a fatal error upon getting 10k collisions (or such)
But that's bad too, especially with servers written in PHP.
 
@bwoebi Not in it's current state. But to refactor the entire thing to randomize the hash function would probably be impractical.
 
@Sherif I mean CPU time overhead… and that will be too much in any state the hashing code is.
 
@bwoebi Because there are no other fast hashing functions than DJBX33?
 
@Sherif because there are no other fast hashing functions which are distributed and unpredictable enough
 
12:11 AM
I find that kind of hard to believe. Although I've never looked so...
 
At least in a server environment, you also must not be able to reverse-engineer the shared secret (IV or such) via timing attacks @Sherif
 
@Sherif As I said, suddenly everybody is an expert on hashdos
 
@NikiC I still am not an expert… I just have a basic grasp about the issues…
 
I'm pretty good with hash browns
 
@NikiC heh, fair enough
 
12:27 AM
@NikiC Though, I'm pretty sure we could solve 99.999% of HashDos vectors, by throwing an exception upon direct insertion and a few manually selected string-input-to-array-with-input-defined-keys functions. I even suspect this could be good enough... But perhaps I am wrong. Were there any specific issues against that approach?
 
@bwoebi You want to set limits, why not just set the limit on the linked list in the bucket?
Insertion only limit check.
 
16 mins ago, by NikiC
@Sherif As I said, suddenly everybody is an expert on hashdos
 
That should have practically no overhead since you have to traverse the linked list on insertion anyway.
 
… because PHP 7 impl uses open addressing…
 
oh, right PHP 7.
There's where my knowledge is practically null, so...
 
12:31 AM
You can set a limit on how far the actual slot is away from the slot assigned by the hash. Which is basically what I'm proposing.
 
@bwoebi The bucket isn't a doubly linked list in PHP 7?
 
@Sherif It's a heap allocated array.
 
The bucket is an array?
umm, maybe you mean the bucket array?
 
yes, sure?
 
I'm not talking about the array that stores the pointers to the buckets.
 
12:33 AM
… what then?
 
I'm talking about the bucket struct itself.
 
the Bucket struct is a pair of hash (string/integer) + zval
 
Right, but doesn't it also have a prev/next pointer
 
@Sherif no.
 
Wait, so how are hash collisions resolved in PHP 7?
 
12:34 AM
really, look up PHP 7 array format…
@Sherif in an array storing pointers to the Buckets. (open addressing as said)
@Sherif just read jpauli.github.io/2016/04/08/hashtables.html … and then continue discussing
 
Ahh! Makes sense.
 
Anyway, I'm off to bed.
good night.
 
One of these days I'll actually inspect PHP 7 internals!
 
1:05 AM
Hmm. I've just noticed that array_column() works perfectly fine on 2 dimensional arrays, but no longer works on 3 (or more) dimensional one? eg: It's not very usefull on json decoded arrays?
 
is it possible to create a matrix in PHP?
 
@icecub "no longer"? It never did. It was designed that way. Think of it like you would selecting a column from a spread sheet. A spread sheet is 2-dimensional.
 
@Corgs a matrix? Yes. the matrix? No.
 
@Sherif I can understand that, but shouldn't it say "input: a 2 dimensional array" instead "multi-dimensional array" on the official docs? It kinda causes confusion..
 
@icecub A 2 dimensional array is a multi-dimensional array.
 
1:17 AM
@icecub yup
 
@Sherif Again, agreed. But so is a 3 dimensional or more
 
@icecub Sure, no one said otherwise.
 
@littlepootis isnt a matrix a multidimensional array?
 
yes
In most languages, yes.
 
@Corgs The important thing to remember in PHP is that what we call an Array is not actually a vector, but an ordered map.
 
1:19 AM
alright thanks!
 
This part always seems to trip people up. If you want truly fixed vectors you want something more like SplFixedArray.
 
@Danack I AM JUST BOOSTING YOUR PRODUCTIVITY!
 
@FélixGagnon-Grenier I AM JUST BOOSTING YOUR PRODUCTIVITY!
 
 
1 hour later…
2:44 AM
Stop using Wordpress for starters. — Sherif 5 secs ago
I couldn't resist.
 
It's an unauthenticated remote shell (handy for crowd-sourcing your server administration) that also happens to come with a blog. — Paul Crovella 5 hours ago
6
either could I
 
@PaulCrovella You sir, are a winner at the Internet!
... and seriously, Windows Server? And... IIS?!
WTF is wrong with people?
It's not bad enough you're using WordPress you also have to go and use a Windows server and IIS?
That's like adding insult to injury.
 
it's better than using windows server with apache, which is just friggin' weird
 
Why use Windows in a production box that serves PHP, at all?
You just had a few extra cents burning a hole in your pocket that you opted for the Windows licensing on AWS?
That's an extra $7.2/month you could spend on a premium latte man :p
2 lattes at Starbucks, in fact.
 
3:11 AM
I look at all the PHP bounties and just see , basically all the crap I'm not interested in answering if you paid me to.
 
that's perfect then - they won't pay you
 
I won't be paying you, answer my question.
 
@PaulCrovella I meant even if you paid me to I wouldn't want to answer.
@littlepootis Shuddup!
 
@Sherif pls
 
Physical server: AWS t2.small; 2 GB memory; CPU 1 core up to 3.3 GHz, OS: Windows Server 2012 2GB is tiny for a server. — ArtisticPhoenix 8 mins ago
That's amusing to me. People think 2GB is tiny?
I ran all of phplab.io on 500MB of memory.
...and with 100% uptime in the last 90 days
 
3:18 AM
Moin
 
:~$ free -m
             total       used       free     shared    buffers     cached
Mem:           488        429         59         64         51        210
-/+ buffers/cache:        167        321
Swap:            0          0          0
That's how you optimize biatch!
 
3:40 AM
you've earned your monthly latte
 
@PaulCrovella heh, it costs me $4.68/month to run a t2.nano on AWS in US WEST, so yea, that's about the price of a latte at Starbucks.
 
Was trying out something, but couldn't figure out where the memory leak is occurring... any hints? gist.github.com/SaitamaSama/6352895508572d3fa7b333eb5ed00ba0
 
@Saitama What do you mean by "memory leak" here? You can't leak memory from PHP code. Only a PHP extension or the memory manager itself can do that since they're the only ones responsible for allocating memory.
 
That memory leak usually occurs when I fuck up something in a separate thread... And the fucked up thing causes pthreads to leak memory...
Also if this is of any help, the output of the program:
lelouch@Geass ~/IPCTest $ php server.php
zend_mm_heap corrupted
string(24) "Date received: Huehuehue"
 
3:56 AM
morning
 
\o
 
Well, you don't join here. I take it the thread might start reading before resource is available.
 
O/.
 
Isn't there some threadsafe way to pass the resource? I don't know that they're inherently threadsafe, but you might want to ask Joe about that.
I don't use pthreads.
> Warning Relying on the engine to determine when a Thread should join may cause undesirable behaviour; the programmer should be explicit, where possible.
 
@Sherif yeah usually if you pass resources they get changed to false and to make it thread safe, wrapping the socket in a simple wrapper like this, does the job:
class Stream extends Threaded {
    public $stream;

    public function __construct($stream) {
        $this->stream = $stream;
    }
}
 
4:00 AM
You think it does the job. I doubt that it does.
What you might be looking for here is Collectable not Thread.
Then again, I've never really touched pthreads in PHP before so... I may have no clue what I'm talking about.
 
Wes
5:20 AM
hm. strange dream i had. ron swanson and neil degrasse tyson bragging about their mustache
there was more but that's what i remember
 
@Wes try lucid dreaming!
...
!!? lucid dreaming
 
Search for "lucid dreaming" (https://www.google.com/search?q=lucid+dreaming&lr=lang_en)
• Lucid dream - Wikipedia, the free encyclopedia - A lucid dream is any dream during which the dreamer is aware that they are dreaming. During lucid d… (https://en.wikipedia.org/wiki/Lucid_dream)
• World of Lucid Dreaming: Learn How to Control You… - The World of Lucid Dreaming is the planet's #1 resource for learning how to have lucid dreams, cont… (http://www.world-of-lucid-dreaming.com/)
• Lucid Dreaming Frequently Asked Questions Answere… - 16 feb. 2015 - Lucid Dreaming FAQ: Lucidity Institute answer
 
Wes
@Saitama til
 
I've heard it's an awesome experience
 
it is
 
5:30 AM
You've tried it?
 
Wes
i only know that i would get addicted to it and turn my life into inception and eventually die
 
5:54 AM
@Sherif I'd still call it leak if you keep references accidentally and they're thus never GCed.
 
WTH!
checking Check for supported PHP versions... configure: error: not supported. Need a PHP version >= 5.4.0 and < 7.1.0 (found 7.1.0RC2)
 
@Saitama no, but it has happened to me on occasion
 
6:14 AM
Good morning
!!rebecca
 
@Epodax Happy Prebeccaday!
 
@Gordon I see
 
@Saitama Are you ever getting a season 2?
 
Dunno... But the rumors say that it's gonna be coming out during the last part of this year or during the beginning of 2k17
 
Sweet
 
6:28 AM
Anyways I'm anxious for Re:Zero, Tokyo Ghoul, Boku no Hero academia, Tales of Zestiria - all these's next season...
<3 my wallpaper
 
6:49 AM
As in, if they'll get a next season?
 
yep
btw have you watched Re:Zero?
can anyone please make me understand how stream_select / socket_select works?
i.e. how to use it...
this what I've done so far... sender.php | parent.php
y u do this md?
 
@DaveRandom <3 gonna try 'n see what's going on there...
umm I get an infinite loop kinda thing when I start the parent like: $ php parent.php and send a message $ php sender.php HelloThere...
and this is the output - Got data from client #6: Got data from client #6: x 10000
 
@Saitama Isn't that the point to get a loop? :P
 
No?
 
Fuck it, if I'm ever inventing a language, I'll find a use for parenthetical ¡! AND ¿?
 
or rather a language consisting only of sequences of '🖕'
 
7:23 AM
@Saitama It's the entire point of while(true) :-)
 
🖕🖕🖕 🖕 🖕🖕🖕🖕 🖕🖕🖕🖕 🖕🖕🖕🖕🖕🖕 🖕 🖕🖕🖕.
 
🖕🖕🖕🖕 🖕🖕🖕🖕🖕🖕 🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕 🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕.
 
@PeeHaa Ich bin davon überzeugt, dass es nicht schlim ist :p
 
:)
That late a response... You need to work on your pünktlichkeit
 
@PeeHaa tht was a late question ;) at the time you've asked, I was in the academy already
 
7:30 AM
@Saitama on school run duty, back in ~half an hour
 
@DaveRandom np \o
 
morninV2
 
@DaveRandom fixed it!
<?php declare(strict_types = 1);

$server = stream_socket_server("tcp://127.0.0.1:47806");
$clients = [];
while (true) {
    $r = array_merge([$server], $clients); // create a copy of $clients
    $w = $e = null; // in this simple example we aren't watching anything for writability or OOB data
    // how long (max) select() will block waiting for something to happen
    $timeoutSecs = 1;
    $timeoutUSecs = 0;
    if (stream_select($r, $w, $e, $timeoutSecs, $timeoutUSecs) > 0) {
        // if something has happened on a socket then process it
^ did it's job
 
morning
 
hey all
 
7:37 AM
@Naruto jo
 
RT @raganwald: Fuck it, if I'm ever inventing a language, I'll find a use for parenthetical ¡! AND ¿?
 
@PeeHaa tweet2 ?
 
Just like regular !!tweet only better
 
okay... :|
 
7:39 AM
what a noob. no tweet0 and tweet1 ?
 
Anonymous
morn
 
@JayIsTooCommon 'in
 
I bet this bot was written by @Ocramius
o/
 
can you any suggest me best PHP book so that i become good and advance developer from scratch
 
are there PHP books? I didn't read any...
but I saw "PHP 6: in original" one. This is why I didn't read even one book :p
 
7:44 AM
ohh so how can improve my php skills
 
Now, that you asked me, stay awhile and listen. It is a simple truth - that not a single book can make an advanced and good developer in any language
 
@AlmaDo Books are good for getting a good basis imo, practice and experience does the rest
Keep a group of friends smarter than you, etc. etc.
 
Unfortunately, people tend not to have patience and jump right into the topic of creating Spotify with CakePHP. And that's how PHP got it's reputation
 
so how should i improve i practised a lot ?
 
@Sean well.. I started at times when there were only paper books in the library and those were about pretty much science-related stuff. And there was no google available
 
7:47 AM
@RebeccaJoanna What worked for me is hanging out in here a lot:)
 
i do that really but i wanna some good reference also
 
And just making terrible things
 
@RebeccaJoanna you should also think twice about going with PHP. Because @PeeHaa was also creating that (:
 
Anonymous
@RebeccaJoanna Keep practising and what @Sean said is bang on, keep a group of friends that are smarter than you but not dicks :D.
 
ohh My GOD
 
Anonymous
7:49 AM
!!wotd
 
flavescent: turning yellow; yellowish.
 
@PeeHaa who care
 
@RebeccaJoanna ?
 
okay thank you all
 
@PeeHaa Can confirm. Yous are the best :P
 
7:50 AM
what's wotd ?
 
@PeeHaa your reputation got reputation++?
 
word of the day?
 
Yup ^
 
@AlmaDo Word Of The Day
yes
 
just joking I do not even understand Peehaa
 
7:51 AM
ah.. so I have it under my 11 command
let's see..
$ 11
                    E.g. null++ == 1, but null-- == null
 
Wes
you know the day's gonna end bad when it starts with a cup of coffee you forgot to add sugar to
mornings :B
 
\O
 
@RebeccaJoanna I was talking about the "1) make something 2) realize it sucks 3) learn from your mistakes / experience 4) goto 1" improvement loop
 
jo Wesley
 
Wes
yo saitamo
 
7:52 AM
thanks @JayIsTooCommon and @AlmaDo and all others for best wishes
 
That and having smart people around you
 
@PeeHaa that's some spaghetti code you got there
 
That works way better (for me) than trying to learn something from books
 
Anonymous
^
 
Wes
and anyway, everybody is in love with joe, admit it
 
7:53 AM
I know I am
 
Wes
i added too much sugar now gosh
 
@Wes ... get a new vup of coffee already
 
@RebeccaJoanna stay connected with people who regularly point out problems in your code and give you assignment and reading book is good i will suggest PHP for absolute beginner
 
lelouch@Geass ~/IPCTest $ php sender.php Hey_You
lelouch@Geass ~/IPCTest $ php server.php
Got a new client #6
New data from client #6: Hey_You
New data from client #6: Wanna play Ping-Pong?
New data from client #6: Answer Me! Will ya?
 
@mas
@Masroor_Shah thank you boy
 
8:00 AM
@RebeccaJoanna just don't look for smart people in this room. Here are php internals after all (:
 
haha okay
leaving take you all bye will come as nicer developer in future
 
ah come on, don't leave, we could still give a nice talk about non-php stuff.. like.. helicopters?
 
Wes
@RebeccaJoanna how much php do you know so far?
 
yomin
 
moryo
 
8:03 AM
yello
 
@Wes I'm sad that I missed that proclamation of love ...
 
Wes
:P
 
I'm secretly in love with you to, Joe. 😍
 
everybody loves Joe, right?
 
@Saitama OK... now why did that fix it?
also note that it didn't actually fix it, it just hid the problem ;-)
 
8:07 AM
/me blushes
 
@DaveRandom hmm...
so why was the infinite loop happening in the first place tho?
 
@Wes i know little about PHP only custom coding
Think of Best Framework but little which one to select
*think and little Confused which one to select
 
don't use any frameworks in the first place, IMO
 
I am using twig and I also use spl_autoload_register(function ( $class ...
When I include both twigs autoloader and my own autoload.php file they clash.
I thought spl_autoload_register would prevent that :o?
Oddly enough it works if I first include the twig autoloader and my own after..
Any ideas?
I am using Twig_Autoloader::register(); and not composer.
 
Define "clash"
 
8:14 AM
my own autoloader tries to load the twig classes and can't so it throws an error
 
Wes
the industry standard is symfony i'd say @RebeccaJoanna but quality code is often written without a framework. you don't need one, but if you want to get a programmer job you likely need to learn one
 
@Schoening Your autoloader is broken
autoloaders should never ever throw errors when they cannot find something
 
^
 
Alright
Would you mind to take a look? hastebin.com/edisivigew.php
 
o/ from Malaysia
 
8:15 AM
o/
 
\o
 
\o/
 
Wes
@Fabor watching the F1 GP next week? :B
 
how's the view?
 
@Schoening Yeah that's wrong
require_once
 
Anonymous
8:16 AM
Also, don't rush into a framework until you have the basics of OOP under your belt @RebeccaJoanna. You'll find frameworks a lot easier to understand and you'll probably use them better if you understand OOP
 
You should do a file_exists
 
Anonymous
@Fabor o/
 
Negative. F1 isny my style
 
Wes
booo
 
@Fabor same
 
Anonymous
8:17 AM
How's life @Fabor you still doing farmwork atm?
 
Malaysia? But i hardly even _know_ her.
 
just random cars going around for INF laps
 
@PeeHaa ahh.. so do a file_exists and if it doesn't do nothing?
 
Anonymous
@Wes I've been meaning to watch last weeks, apparently it was a good'n ?
 
@Schoening What do you mean by "and if it doesn't do nothing"?
You mean if the file indeed doesn't exist?
 
Wes
8:19 AM
@JayIsTooCommon F1 hasnt been good since 1990 :B
 
Anonymous
by good'n I mean there was a decent crash :P
 
@PeeHaa yes
 
Wes
but yeah this year's championship is okish. and no, no crashes :D
 
@Schoening If the file doesn't exists it will try the next autoloader on the stack (twig's one)
 
@Saitama OK so why might a client be readable but return no data when you read from it?
 
Anonymous
8:21 AM
British or not, I'm still no fan of Hamilton. I root for RIcciardo most of the time.
 
@DaveRandom because all the data from it has been consumed?
 
@PeeHaa That sounds like a yes :p Aaaand it works! Thank you! php knowledge +1
 
\o/
 
@Saitama Note that "readable" in this case simply means that a packet was recieved, and remember that these are TCP clients
and think what happens when your client script finishes in terms of the socket it created
 
umm... didn't get you there...
 
8:24 AM
@Saitama TCP is a stateful protocol. It has an initial synchronisation, data is exchanged, and a graceful disconnect where one peer informs the other that it is closing the connection
 
ah, so someone has to close the connection explicitly... right?
 
@Saitama yes, except that when you client script finishes, PHP does that for you.
so when a socket is readable but has no data, it means that it has disconnected
 
ah.. sou ka
 
so you need to remove it from the array
moment, let me show you how I would deal with this
 
dealwithit.gif
 
8:26 AM
hmm so if(strlen($data) > 0) { ... } else { /* remove the thing */ }
and if I want to make this connection a infinitely running then none of the processes should be terminated.
And I wish to implement this in the websocket server of mine for IPC, so it's gonna be infinitely running as well....
 
going through it atm!
 
Morning.
 
Where it says "do anything else you might need do..." the "anything else" refers to alarms/timers (i.e. what JS exposes via the setTimeout() function) @Saitama
 
got it..
 
8:38 AM
So when you have that functionality, you obviously use that to define the timeout (it doesn't have to be 1 second)
And note that you can pass null to the timeout seconds arg to have it wait forever
 
noted
btw when I do a $ php sender.php {MESSAGE} the parent only spits out:
....
Loop tick
Loop tick
1 sockets have readable activity
Got a new client #6
Loop Tick
 
oh god damn it
change $clients[$clientId] to $readSockets[$clientId] @Saitama
 
got it
<3 works like a charm
hmm I also think that I got the hang of it now... thanks for clearing things up for me!
 
Also @Saitama what I haven't done there is called stream_set_blocking(). It's not actually necessary for reads when you are using select(), because the code doesn't actually try to read until there's data available, and the way fread() etc work internally means that it won't block waiting for more data because it will return data at packet boundaries. However if you are doing writes on the sockets, you need to set them to non-blocking and use the $w parameter of select()
 
Welp, even more people think that keeping BC is the ultimate problem. Hey, let's forever make this useless instead of fixing it literally the next release after it was created! Oh, and in other news PHP 4 has as much adoption as 7.0!
 
8:45 AM
yeah I was gonna ask you that eventually
 
I really just don't understand people. It's like they look at the BC rules and throw everything else out of the window.
 
because it would be broadcasting the message it received from one client to all of the clients...
 
@JayIsTooCommon Nah, now in Langkawi, Malaysia helping on a resort
This place is empty(true);
 
Anonymous
all good?
 
so what would the param $w be in that case
 
8:47 AM
Also @Saitama it's worth noting that select() is not actually a particularly efficient way of implementing this - it's not very good for high-concurrency applications because of the way it works internally. It's a good way to learn and understand how event loops work from a logic PoV, but if you are writing a real-world application you should use something like libev, which uses kqueue/epoll internally.
@Saitama I'll modify the server code to send a response so you can see
 
@Andrea Cheers
 
hmm, I heard of libev, but never used it...
@DaveRandom that's so nice of you :), thanks!
 
@Saitama If the purpose of this exercise is just to learn about event loops, don't worry about it for now because select() is the best tool for that task. If the purpose is to eventually write a real-world application, then still keep using select for now while you are learning, but once you understand it go and take a look at how amp works. It has adapters for libev etc.
 
@DaveRandom it's totally an exercise kinda thing, so probably gonna be using select() for now... but thanks for letting me know 'bout libev and the amp adapters!
 

« first day (2168 days earlier)      last day (2766 days later) »