Good afternoon, I'm getting a stack overflow error when I try to use DJDT 1.8 on routes served by the Wagtail CMS. The same routes / pages work with DJDT 1.7. I'm running Django 1.11.2 and Wagtail 1.10.1. Here's the trace:
Fatal Python error: Cannot recover from stack overflow.
Current thread 0x00007f5d3f7f8700 (most recent call first):
File "/venv-path/django/utils/functional.py", line 215 in wrapper
File "/venv-path/django/template/base.py", line 835 in __init__
File "/venv-path/django/template/base.py", line 685 in __init__
File "/venv-path/django/template/base.py", line 600 in compile_filter
File "/venv-path/django/template/defaulttags.py", line 826 in do_for
File "/venv-path/django/template/base.py", line 513 in parse
File "/venv-path/django/template/base.py", line 230 in compile_nodelist
File "/venv-path/django/template/base.py", line 191 in __init__
File "/venv-path/django/template/loaders/base.py", line 44 in get_template
File "/venv-path/django/template/engine.py", line 136 in find_template
File "/venv-path/django/template/engine.py", line 162 in get_template
File "/venv-path/django/template/backends/django.py", line 39 in get_template
File "/venv-path/django/template/loader.py", line 21 in get_template
File "/venv-path/django/template/loader.py", line 67 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
File "/venv-path/django/template/backends/django.py", line 66 in render
File "/venv-path/django/template/loader.py", line 68 in render_to_string
File "/venv-path/wagtail/wagtailcore/blocks/base.py", line 259 in render
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 377 in __html__
File "/venv-path/wagtail/wagtailcore/blocks/stream_block.py", line 380 in __str__
File "/venv-path/django/utils/encoding.py", line 76 in force_text
File "/venv-path/debug_toolbar/panels/templates/panel.py", line 128 in _store_template_info
File "/venv-path/django/dispatch/dispatcher.py", line 193 in <listcomp>
File "/venv-path/django/dispatch/dispatcher.py", line 193 in send
File "/venv-path/django/test/utils.py", line 106 in instrumented_test_render
File "/venv-path/django/template/base.py", line 207 in render
...
Thread 0x00007f5d4bcb3700 (most recent call first):
File "/usr/lib64/python3.5/selectors.py", line 376 in select
File "/usr/lib64/python3.5/socketserver.py", line 232 in serve_forever
File "/venv-path/django/core/servers/basehttp.py", line 174 in run
File "/venv-path/django/core/management/commands/runserver.py", line 149 in inner_run
File "/venv-path/django/utils/autoreload.py", line 227 in wrapper
Thread 0x00007f5d61887740 (most recent call first):
File "/venv-path/django/utils/autoreload.py", line 281 in reloader_thread
File "/venv-path/django/utils/autoreload.py", line 298 in python_reloader
File "/venv-path/django/utils/autoreload.py", line 332 in main
File "/venv-path/django/core/management/commands/runserver.py", line 110 in run
File "/venv-path/django/core/management/commands/runserver.py", line 101 in handle
File "/venv-path/django/core/management/base.py", line 330 in execute
File "/venv-path/django/core/management/commands/runserver.py", line 62 in execute
File "/venv-path/django/core/management/base.py", line 283 in run_from_argv
File "/venv-path/django/core/management/__init__.py", line 355 in execute
File "/venv-path/django/core/management/__init__.py", line 363 in execute_from_command_line
File "manage.py", line 15 in <module>
Aborted
I'm fine with running 1.7 for now, but am at a loss with where to start digging into this issue. Any ideas, advice, or hopefully solutions? Thanks in advance.
I can confirm the same problem when using DDT 1.8 with Django 1.8.
I've seen the same issue--it was triggered for me when using a StreamField block that specified a template. Adding that template to the SKIP_TEMPLATE_PREFIXES
debug toolbar config was a workaround. As I recall (though it was some time ago), the root issue was that the block object renders a template in its __str__
method, which led to infinite recursion in the TEMPLATES panel of the debug toolbar.
@gasman I thought you might want to have a look at this issue.
Possibly related to https://github.com/wagtail/wagtail/issues/2874...?
I've experienced the same thing with DDT 1.8, Django 1.11.2 and Wagtail 1.10.1.
Reproduced it with Python 3.6, 3.6.1 and 3.7a
After some investigation, there is an infinite loop created in panels.py:128, in Wagtail's case the value
here can be a StructValue which string representation is actually a template rendering which triggers a signal template_rendered
.
I've monkey-patched it to get it working for those using Wagtail. The patch is here:
https://github.com/FlipperPA/django-debug-toolbar/commit/e68cfa509566bf5332c37f03c0fd9753a873d491
I don't expect this should be a P.R., since it is Wagtail specific.
Another hotfix for this is to exclude templates used by StructBlock
from debug toolbar. E.g.
class MyStructBlock(StructBlock):
...
class Meta:
...
template = 'myblocks/structblock.html'
And add to settings.py
file:
DEBUG_TOOLBAR_CONFIG = {
'SKIP_TEMPLATE_PREFIXES': ('django/forms/widgets/', 'admin/widgets/', 'myblocks/structblock.html'),
}
From DDT doc for SKIP_TEMPLATE_PREFIXES
:
Templates starting with those strings are skipped when collecting rendered templates and contexts. Template-based form widgets are skipped by default because the panel HTML can easily grow to hundreds of megabytes with many form fields and many options.
Works for me.
We had this issue with Django Debug Toolbar 1.8 and django-floppyforms and fixed this problem in a similar way:
DEBUG_TOOLBAR_CONFIG = {
'SKIP_TEMPLATE_PREFIXES': (
'django/forms/widgets/',
'admin/widgets/',
'floppyforms/'
),
'DISABLE_PANELS': {
'debug_toolbar.panels.redirects.RedirectsPanel',
'debug_toolbar.panels.redirects.TemplatesPanel'
},
}
We also decided to disable the TemplatesPanel by default because it was slowing the page heavily. Page loads were three times as slow in comparison with Django Debug Toolbar 1.7.
Fixed in https://github.com/wagtail/wagtail/pull/3738 - I think this can be closed, as it's a Wagtail issue.
Thanks @gasman!
Also affects django-el-pagination==3.1.0
, adding 'el_pagination/',
to SKIP_TEMPLATE_PREFIXES
helps.
Most helpful comment
Possibly related to https://github.com/wagtail/wagtail/issues/2874...?