Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8314 closed (fixed)

rev 8340 breaks sessions while rev 8339 works

Reported by: anonymous Owned by: nobody
Component: contrib.sessions Version: dev
Severity: Keywords:
Cc: carl@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Malcolm Tredinnick)

[Thu Aug 14 11:37:26 2008] [error] [client XXX] mod_wsgi (pid=22633): Exception occurred processing WSGI script '/var/www/html/XXX/XXX-trunk/XXX.XXX.com.wsgi.py'.
[Thu Aug 14 11:37:26 2008] [error] [client XXX] Traceback (most recent call last):
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/core/handlers/wsgi.py", line 216, in __call__
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     response = self.get_response(request)
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/core/handlers/base.py", line 67, in get_response
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     response = middleware_method(request)
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/XXX-trunk/XXX/site/middleware.py", line 81, in process_request
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     request.session['foo'] = "bar"
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/base.py", line 49, in __setitem__
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self._session[key] = value
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/base.py", line 161, in _get_session
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self._session_cache = self.load()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 19, in load
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.create()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 35, in create
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.save(must_create=True)
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 52, in save
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     session_data = self.encode(self._session),
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/base.py", line 161, in _get_session
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self._session_cache = self.load()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 19, in load
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.create()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 35, in create
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.save(must_create=True)
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 52, in save
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     session_data = self.encode(self._session),
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/base.py", line 161, in _get_session
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self._session_cache = self.load()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 19, in load
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.create()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 35, in create
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.save(must_create=True)
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 52, in save
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     session_data = self.encode(self._session),
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/base.py", line 161, in _get_session
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self._session_cache = self.load()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 19, in load
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.create()
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 35, in create
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     self.save(must_create=True)
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/db.py", line 52, in save
[Thu Aug 14 11:37:26 2008] [error] [client XXX]     session_data = self.encode(self._session),
[Thu Aug 14 11:37:26 2008] [error] [client XXX]   File "/var/www/html/XXX/django-trunk/django/contrib/sessions/backends/base.py", line 161, in _get_session
.....
RuntimeError: maximum recursion depth exceeded in cmp

Attachments (1)

session-fix.diff (1.8 KB ) - added by anonymous 16 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by Malcolm Tredinnick, 16 years ago

Description: modified (diff)
milestone: 1.0 beta
Version: 1.0-alphaSVN

comment:2 by Killarny, 16 years ago

I can confirm that this is an issue. I haven't been able to recreate it again, but I definitely had a "recursion depth exceeded in cmp" problem. I reverted back to 8339 after seeing this ticket, and was able to view my site properly. Moving back up to 8340 caused the error again, which was resolved by clearing cookies in my browser. Now, I am unable to recreate the issue even by logging in under 8339 and updating to 8340, so I'm not certain what's going on. Thought I'd share though :)

comment:3 by Carl Meyer, 16 years ago

Cc: carl@… added

comment:4 by anonymous, 16 years ago

It looks like base.py's SessionBase._get_session calls db.py's SessionStore.load() which calls SessionStore.create() which calls SessionStore.save() which tries to read _session which implicitly calls SessionBase._get_session recursively and the whole process repeats until we run out of stack.

Should SessionStore.save() instead skip the session_data = self.encode(_session) if we're trying to create the session since there isn't anything in it yet?

by anonymous, 16 years ago

Attachment: session-fix.diff added

comment:5 by anonymous, 16 years ago

I have no idea if this is the right way to fix this, but the attached patch fixes the problem for me.

comment:6 by Alex Gaynor, 16 years ago

Triage Stage: UnreviewedAccepted

comment:7 by anonymous, 16 years ago

PS, not sure if the same recursion problem exists for the cache or file backends. I am only using the DB backend.

comment:8 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [8351]) Fixed #8314 -- Fixed an infinite loop caused when submitting a session key (via
a cookie) with no corresponding entry in the database.

This only affected the database backend, but I've applied the same fix to all
three backends for robustness.

comment:9 by anonymous, 16 years ago

Looks like this fixed the problem for me.

comment:10 by Jacob, 13 years ago

milestone: 1.0 beta

Milestone 1.0 beta deleted

Note: See TracTickets for help on using tickets.
Back to Top