Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8314 closed (fixed)

rev 8340 breaks sessions while rev 8339 works

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

Description (last modified by mtredinnick)

[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 7 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by mtredinnick

  • Description modified (diff)
  • milestone set to 1.0 beta
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from 1.0-alpha to SVN

comment:2 Changed 7 years ago by Killarny

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 Changed 7 years ago by carljm

  • Cc carl@… added

comment:4 Changed 7 years ago by anonymous

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?

Changed 7 years ago by anonymous

comment:5 Changed 7 years ago by anonymous

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

comment:6 Changed 7 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:7 Changed 7 years ago by anonymous

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

comment:8 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 7 years ago by anonymous

Looks like this fixed the problem for me.

comment:10 Changed 4 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

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