RejectedSoftware Forums

Sign up

Bug on Session

Hello !

I add this issue to github : https://github.com/rejectedsoftware/vibe.d/issues/889

It describes a problem I'm facing with vibe.d sessions and tried to catch it with valgrind but could not get any clue with that.

Also today I noticed that even after it show a corrupted session after a while without reset the session it sometimes start returning a correct session value.

This problem makes the usage of the actual Session mechanism not usable.

Any help on this will be appreciated !

Cheers !

Re: Bug on Session

Here is a dump of the data been show corrupted and after a while without reset become normal again.

deserialize: 7F00C22AF030:UserSession(true, false, "DAD", "", 333, "\0\0\0\0\0\0\0\0\0", true, "", "", 0001-Jan-01 00:00:00)
checkauth : / : : 127.0.0.1 : 1 : DAD
MemorySessionStore.get:7F00C4DFDD20::UserSession(true, false, "DAD", "", 333, "\0\0\0\0\0\0\0\0\0", true, "", "", 0001-Jan-01 00:00:00)
deserialize: 7F00C22AF030:UserSession(true, false, "DAD", "", 333, "\0\0\0\0\0\0\0\0\0", true, "", "", 0001-Jan-01 00:00:00)
check
auth : / : : 127.0.0.1 : 1 : DAD
MemorySessionStore.get:7F00C4DFDD20::UserSession(true, false, "DAD", "", 333, "127.0.0.1", true, "", "", 0001-Jan-01 00:00:00)
deserialize: 7F00C22AF030:UserSession(true, false, "DAD", "", 333, "127.0.0.1", true, "", "", 0001-Jan-01 00:00:00)
check_auth : / : 127.0.0.1 : 127.0.0.1 : 1 : DAD

Re: Bug on Session

And here I dumped the data with cast(ubyte[40]) and it shows that the memory is not corrupted but the deserialized data is:

checkauth : /login : : 127.0.0.1 : 0 :
MemorySessionStore.get:7FAAEA38FD20::UserSession(true, false, "DAD", "", 333, "127.0.0.1", true, "", "", 0001-Jan-01 00:00:00)
MemorySessionStore.get:[52, 226, 95, 0, 0, 0, 0, 0, 128, 253, 56, 234, 170, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
deserialize: 7FAAE7841030:UserSession(true, false, "DAD", "", 333, "127.0.0.1", true, "", "", 0001-Jan-01 00:00:00)
check
auth : / : 127.0.0.1 : 127.0.0.1 : 1 : DAD
MemorySessionStore.get:7FAAEA38FD20::UserSession(true, false, "DAD", "", 333, "\0\0\0\0\0\0\0\0\0", true, "", "", 0001-Jan-01 00:00:00)
MemorySessionStore.get:[52, 226, 95, 0, 0, 0, 0, 0, 128, 253, 56, 234, 170, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
deserialize: 7FAAE7841030:UserSession(true, false, "DAD", "", 333, "\0\0\0\0\0\0\0\0\0", true, "", "", 0001-Jan-01 00:00:00)
check_auth : / : : 127.0.0.1 : 1 : DAD

Re: Bug on Session

A friend pointed that the binary shown is not useful because string contents are not in the structure but elsewhere.

Variant get(string id, string name, lazy Variant defaultVal)
{
	assert(id in m_sessions, "session not in store");
	foreach(k, v; m_sessions[id]) logTrace("Dsession[%s][%s] = %s", id, k, v);
	if (auto pv = name in m_sessions[id]) {
		import std.stdio;
		writeln("MemorySessionStore.get:", pv, "::", *pv);
		writeln("MemorySessionStore.get:", cast(ubyte[40])*pv);
		return *pv;
	} else {
		return defaultVal;
	}
}

Re: Bug on Session

Pointed again by a friend the 40 bytes would not be enough to see the possible corrupted data so I tried 140 bytes (cast(ubyte[140]) but dmd 2.0.65 do not accept it and do not compile even any of this values (120, 100, 80, 60, 50).

And gdc 2.0.65 do not accept those casts.