mikitex70 / redmine_drawio

Macro plugin to embed draw.io diagrams into Redmine wiki pages
MIT License
123 stars 51 forks source link

SystemStackError (stack level too deep) when using Redmine 4.0.3 #66

Closed bigbrozer closed 5 years ago

bigbrozer commented 5 years ago

Hey ! Thanks for this excellent plugin :heart: ! I did have an issue that seems to be fixed by removing the following in lib/redmine_drawio.rb:

  require 'redmine_drawio/helpers/drawio_dmsf_helper'
- require 'redmine_drawio/helpers/textile_helper'
  require 'redmine_drawio/helpers/markdown_helper'

This is a 🤮 workaround but at least, there is something in this module which cause Redmine Settings page to fail...

Environment

How to reproduce ?

Processing by SettingsController#index as HTML
redmine_1     |   Current user: user (id=1)
redmine_1     |   Rendering settings/edit.html.erb within layouts/admin
redmine_1     |   Rendered settings/_general.html.erb (7.8ms)
redmine_1     |   Rendered common/_tabs.html.erb (9.2ms)
redmine_1     |   Rendered settings/edit.html.erb within layouts/admin (9.4ms)
redmine_1     | Completed 500 Internal Server Error in 15ms (ActiveRecord: 2.1ms)
redmine_1     |   
redmine_1     | SystemStackError (stack level too deep):
redmine_1     |   
redmine_1     | plugins/redmine_drawio/lib/redmine_drawio/helpers/textile_helper.rb:6:in `heads_for_wiki_formatter_with_drawio'
redmine_1     | lib/redmine/wiki_formatting/textile/helper.rb:23:in `wikitoolbar_for'
redmine_1     | app/views/settings/_general.html.erb:7:in `block in _app_views_settings__general_html_erb__3307274441618817858_70285639634000'
redmine_1     | app/views/settings/_general.html.erb:1:in `_app_views_settings__general_html_erb__3307274441618817858_70285639634000'
redmine_1     | app/views/common/_tabs.html.erb:17:in `block in _app_views_common__tabs_html_erb__1573495077388599801_70285639581460'
redmine_1     | app/views/common/_tabs.html.erb:16:in `each'
redmine_1     | app/views/common/_tabs.html.erb:16:in `_app_views_common__tabs_html_erb__1573495077388599801_70285639581460'
redmine_1     | app/helpers/application_helper.rb:386:in `render_tabs'
redmine_1     | app/views/settings/edit.html.erb:5:in `_app_views_settings_edit_html_erb__1133682644675227220_70285639542460'
redmine_1     | app/controllers/settings_controller.rb:31:in `index'
redmine_1     | lib/redmine/sudo_mode.rb:63:in `sudo_mode'
mikitex70 commented 5 years ago

My test installation works fine. Have you other installed plugins? I've seen that some plugin not explicitly adapted to Rails 5 can interfere with the redmine_drawio plugin. I you look into the textile_helper.rb and the markdown_helper.rb you can see that are very similar, so it seems strange that only the textile_helper.rb breaks Redmine. The problem seems to be related to the alias_method_chain method (deprecated in Rails 5) that may be used by other plugins.

bigbrozer commented 5 years ago

I did some new tests even with latest redmine v4.0.4 always using the bitnami/redmine image. But still the same issue.

What is interesting is that the issue appears only when logged in. For anonymous, everything is working fine (drawio are only png files after all, correctly displayed on issues / wiki pages).

I have no other plugins installed. Here are some extra details about all used versions:

Environment:
  Redmine version                4.0.4.stable
  Ruby version                   2.6.3-p62 (2019-04-16) [x86_64-linux]
  Rails version                  5.2.3
  Environment                    production
  Database adapter               PostgreSQL
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
SCM:
  Git                            2.22.0
  Filesystem                     
Redmine plugins:
  redmine_drawio                 0.8.3

To help reproducing this, here is the gist to the docker compose file: https://gist.github.com/bigbrozer/6d1f1074313bb2d08df7666f419abeb3.

Thanks for taking time on this. I will continue to search where it could come from but I'm not familiar with Ruby + Rails :smiley:

mikitex70 commented 5 years ago

Ok, I was able to reproduce the error, I was looking in the Redmine administration instead of the project administration. The bug is now should be fixed fixed, and I've kept the compatibility with previous versions of Redmine.

fpaaske commented 3 years ago

I got a similar problem on redmine 3.4.2. It happens when I edit a wiki page with textile formatting, but not for wikis with markdown. I was using the latest version of this plugin when it happened.

Environment:
  Redmine version                3.4.2.stable
  Ruby version                   2.1.4-p265 (2014-10-27) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               Mysql2
SCM:
  Git                            1.7.1
  Filesystem                     
Redmine plugins:
  additionals                    2.0.16
  clipboard_image_paste          1.13
  computed_custom_field          1.0.6
  redmine_issue_templates        0.2.1
  redmine_lightbox2              0.4.3
  redmine_mentions               0.0.1
  redmine_per_project_formatting 0.0.4
  redmine_revision_branches      0.3.2
  redmine_silencer               0.4.3
  redmine_workload               1.1.0
  redmine_xlsx_format_issue_exporter 0.1.5
  sidebar_hide                   0.0.8
  time_logger                    0.5.4
mikitex70 commented 3 years ago

The stack level too deep error is caused by old plugins which conflicts with newer that support the new rails version.Try to upgrade the old or downgrade the too new. For every plugin check in the source repository if there are issues or versions specific for Redmine 3.4 (maybe you have installed a plugin for Redmine 4). And read the README, usually it mentions which version too use for every Redmine version.

The problem appears when using plugins which use the alias_method function (removed in Rails 5). I suggest you to remove all plugins and add them one by one until you get the error. Once you have got the error remove the plugin and try with the remaining, maybe there is more than one causing the error. It's a slow process, but it's not simple to find which is causing the instability.

fpaaske commented 3 years ago

Thanks for the quick response! The error came after adding this plugin and disappeared after I removed this plugin again.

Do you mean that other plugins can conflict with this plugin and that's what's causing this error?

mikitex70 commented 3 years ago

Yes, maybe. But first try pulling again the redmine_drawio plugin. You questioned me and I double-checked the code: I found some code that I had commented to test the textile format, code specific for Redmine 4. So maybe it's my fault. If the error didn't disappear, than other there are other plugins causing the error.

fpaaske commented 3 years ago

Thanks for checking! After pulling latest code I got this error when restarting redmine:

Error message:
/var/www/redmine-3.4.2/plugins/redmine_drawio/lib/redmine_drawio/helpers/textile_helper.rb:49: syntax error, unexpected end-of-input, expecting keyword_end
Exception class:
SyntaxError
Application root:
/var/www/redmine
Backtrace:
#   File    Line    Location
0   /usr/local/lib/ruby/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb  65  in `require'
1   /usr/local/lib/ruby/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb  65  in `require'
2   /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  274 in `block in require'
3   /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  240 in `load_dependency'
4   /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  274 in `require'
5   /var/www/redmine-3.4.2/plugins/redmine_drawio/lib/redmine_drawio.rb 10  in `'
6   /usr/local/lib/ruby/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb  65  in `require'
7   /usr/local/lib/ruby/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb  65  in `require'
8   /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  274 in `block in require'
9   /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  240 in `load_dependency'
10  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  274 in `require'
11  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  360 in `require_or_load'
12  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  317 in `depend_on'
13  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  233 in `require_dependency'
14  /var/www/redmine-3.4.2/plugins/redmine_drawio/after_init.rb 2   in `'
15  /var/www/redmine-3.4.2/plugins/redmine_drawio/init.rb   22  in `require_relative'
16  /var/www/redmine-3.4.2/plugins/redmine_drawio/init.rb   22  in `'
17  /usr/local/lib/ruby/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb  65  in `require'
18  /usr/local/lib/ruby/gems/2.1.0/gems/polyglot-0.3.5/lib/polyglot.rb  65  in `require'
19  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  274 in `block in require'
20  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  240 in `load_dependency'
21  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  274 in `require'
22  /var/www/redmine-3.4.2/lib/redmine/plugin.rb    155 in `block in load'
23  /var/www/redmine-3.4.2/lib/redmine/plugin.rb    146 in `each'
24  /var/www/redmine-3.4.2/lib/redmine/plugin.rb    146 in `load'
25  /var/www/redmine-3.4.2/config/initializers/30-redmine.rb    21  in `'
26  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  268 in `load'
27  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  268 in `block in load'
28  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  240 in `load_dependency'
29  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb  268 in `load'
30  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/engine.rb  652 in `block in load_config_initializer'
31  /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.2.8/lib/active_support/notifications.rb 166 in `instrument'
32  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/engine.rb  651 in `load_config_initializer'
33  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/engine.rb  616 in `block (2 levels) in '
34  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/engine.rb  615 in `each'
35  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/engine.rb  615 in `block in '
36  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/initializable.rb   30  in `instance_exec'
37  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/initializable.rb   30  in `run'
38  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/initializable.rb   55  in `block in run_initializers'
39  /usr/local/lib/ruby/2.1.0/tsort.rb  226 in `block in tsort_each'
40  /usr/local/lib/ruby/2.1.0/tsort.rb  348 in `block (2 levels) in each_strongly_connected_component'
41  /usr/local/lib/ruby/2.1.0/tsort.rb  418 in `block (2 levels) in each_strongly_connected_component_from'
42  /usr/local/lib/ruby/2.1.0/tsort.rb  427 in `each_strongly_connected_component_from'
43  /usr/local/lib/ruby/2.1.0/tsort.rb  417 in `block in each_strongly_connected_component_from'
44  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/initializable.rb   44  in `each'
45  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/initializable.rb   44  in `tsort_each_child'
46  /usr/local/lib/ruby/2.1.0/tsort.rb  411 in `call'
47  /usr/local/lib/ruby/2.1.0/tsort.rb  411 in `each_strongly_connected_component_from'
48  /usr/local/lib/ruby/2.1.0/tsort.rb  347 in `block in each_strongly_connected_component'
49  /usr/local/lib/ruby/2.1.0/tsort.rb  345 in `each'
50  /usr/local/lib/ruby/2.1.0/tsort.rb  345 in `call'
51  /usr/local/lib/ruby/2.1.0/tsort.rb  345 in `each_strongly_connected_component'
52  /usr/local/lib/ruby/2.1.0/tsort.rb  224 in `tsort_each'
53  /usr/local/lib/ruby/2.1.0/tsort.rb  205 in `tsort_each'
54  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/initializable.rb   54  in `run_initializers'
55  /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.8/lib/rails/application.rb 352 in `initialize!'
56  /var/www/redmine-3.4.2/config/environment.rb    14  in `'
57  config.ru   3   in `require'
58  config.ru   3   in `block in
'
59  /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.8/lib/rack/builder.rb  55  in `instance_eval'
60  /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.8/lib/rack/builder.rb  55  in `initialize'
61  config.ru   1   in `new'
62  config.ru   1   in `
'
63  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/rack/application_spawner.rb    225 in `eval'
64  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/rack/application_spawner.rb    225 in `load_rack_app'
65  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/rack/application_spawner.rb    157 in `block in initialize_server'
66  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/utils.rb   563 in `report_app_init_status'
67  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/rack/application_spawner.rb    154 in `initialize_server'
68  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 204 in `start_synchronously'
69  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 180 in `start'
70  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/rack/application_spawner.rb    129 in `start'
71  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   253 in `block (2 levels) in spawn_rack_application'
72  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  132 in `lookup_or_add'
73  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   246 in `block in spawn_rack_application'
74  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  82  in `block in synchronize'
75  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  79  in `synchronize'
76  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb  79  in `synchronize'
77  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   244 in `spawn_rack_application'
78  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   137 in `spawn_application'
79  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb   275 in `handle_spawn_application'
80  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop'
81  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously'
82  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.19/helper-scripts/passenger-spawn-server    99  in `
'
mikitex70 commented 3 years ago

My fault, one line was left commented. Maybe I'm working too hard... Try again, now it should work.

fpaaske commented 3 years ago

Thank you @mikitex70! It seems to work well now 👍