-
Notifications
You must be signed in to change notification settings - Fork 284
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
Session storage returns garbage #889
Comments
|
My friend helped me to narrow down the problem somehow, it seems that the problem is that the HTTPServerRequest.peer having it's origin from a range of a char[64] variable is the problem, the range remain pointing to the memory but the memory content changes. Windows also use the same way to return the peer string. Probably more usages like this need to be revised on other parts of the code. !!!! WATCH OUT TO RETURNING RANGES !!!! |
|
That's odd... why not just use |
|
Good question ! I didn't tried to look further because it took me almost 2 days to found this and I was exausted. And also I di a search for ".." and there is usages like this on other places that can lead to unexpected behavior on some circusntances. Cheers ! |
|
Yes, I'd love to know if the native events (libasync) branch could also contain these errors. Thanks for the diagnostics and heads up! |
|
Yes, big thanks for tracking down the cause! Basically the issue that we have here is that the The offending line of code is here where the
My goal for the next version is to start deprecating non-scoped request handlers, so that the compiler can start to detect these kinds of bugs. Unfortunately DMD's enforcement of |
|
So to state this more explicitly, the reason the code works like that is an intentional optimization to avoid a GC allocation. For that reason, |
Or, maybe even prioritize lazy evaluation pretty much everywhere. The peer address, HTTP headers, JSON data... Only a few things are needed (URL, compression) when moving into the request handler and otherwise, if the storage of individual elements can be avoided I also assume it will speed up the typical static page delivery. I think there's also a cost associated to zeroing the dictionary list for 64 key/value pointers on every request (only for the headers), so maybe a single string allocation for the entire headers would do. Same for the forms and files. |
|
Also another possible optimization, the FixedRingBuffer could avoid the zeroing of its data segments because it has internal indexing control... |
|
The original issue is fixed when using vibe-core. The |
|
The HTTP improvements/optimizations will be part of the upcoming HTTP package rework. |
Hello !
With this sample we can see that afer some calls we start getting garbage on some of the session member variabls (peer):
Execute this server and browse to "http://127.0.0.1:8086/login" after that browse "http://127.0.0.1:8086/" and we will see on console (check_auth : / : 127.0.0.1 : 127.0.0.1 : 1 : DAD)
then run the "ab" command and again browse "http://127.0.0.1:8086/" and probably we will get this(check_auth : / : ��������� : 127.0.0.1 : 1 : DAD)
ab command:
ab -n 5000 -c 1000 -k http://127.0.0.1:8086/
The text was updated successfully, but these errors were encountered: