ActionView :: Template :: Error (incompatible character encodings : UTF 8 and ASCII 8BIT)


(Sam Saffron) #1

I am seeing this error on a Discourse site

When it happens every visit to the front any page just comes out as a white page.

I suspect this is encoding related, somehow something is getting cached wrong. Perhaps a Rails bug. I tried debugging this but can not find the root cause. Last time it went away after a rebuild which may indicate it is encoding related.

@tenderlove @rafaelfranca have you ever seen anything like this anywhere?

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)

 

/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/core_ext/string/output_safety.rb:176:in `concat'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/core_ext/string/output_safety.rb:176:in `concat'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/buffers.rb:12:in `<<'
/var/www/discourse/app/views/list/list.erb:17:in `_app_views_list_list_erb___19075230255371980_70047495970040'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/template.rb:145:in `block in render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications.rb:161:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/template.rb:339:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/template.rb:143:in `render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiling_methods.rb:79:in `block in profile_method'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications.rb:159:in `block in instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications.rb:159:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/template_renderer.rb:53:in `render_template'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/template_renderer.rb:17:in `render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/renderer.rb:42:in `render_template'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/renderer/renderer.rb:23:in `render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/rendering.rb:99:in `_render_template'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/streaming.rb:217:in `_render_template'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/rendering.rb:82:in `render_to_body'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/rendering.rb:32:in `render_to_body'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/renderers.rb:32:in `render_to_body'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/abstract_controller/rendering.rb:25:in `render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/rendering.rb:16:in `render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/core_ext/benchmark.rb:12:in `ms'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.5/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/instrumentation.rb:40:in `render'
/var/www/discourse/app/controllers/list_controller.rb:190:in `block (2 levels) in respond'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/mime_responds.rb:258:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/mime_responds.rb:258:in `respond_to'
/var/www/discourse/app/controllers/list_controller.rb:186:in `respond'
/var/www/discourse/app/controllers/list_controller.rb:67:in `block (2 levels) in <class:ListController>'
/var/www/discourse/app/controllers/list_controller.rb:71:in `block (2 levels) in <class:ListController>'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/abstract_controller/base.rb:189:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/rendering.rb:10:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:113:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:113:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:229:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:229:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:166:in `block in halting'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:86:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:86:in `run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/abstract_controller/callbacks.rb:19:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/rescue.rb:29:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications.rb:159:in `block in instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/notifications.rb:159:in `instrument'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.5/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/abstract_controller/base.rb:136:in `process'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionview-4.1.5/lib/action_view/rendering.rb:30:in `process'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiling_methods.rb:79:in `block in profile_method'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal.rb:196:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_controller/metal.rb:232:in `block in action'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/routing/route_set.rb:82:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/routing/route_set.rb:50:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/journey/router.rb:71:in `block in call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/journey/router.rb:59:in `each'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/journey/router.rb:59:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/routing/route_set.rb:678:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-protection-1.5.2/lib/rack/protection/frame_options.rb:31:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/omniauth-1.2.1/lib/omniauth/builder.rb:59:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
/var/www/discourse/lib/middleware/anonymous_cache.rb:117:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/flash.rb:254:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/message_bus-0.9.5/lib/message_bus/rack/middleware.rb:55:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/cookies.rb:560:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.5/lib/active_record/query_cache.rb:36:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:82:in `run_callbacks'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/logster-0.1.6/lib/logster/middleware/reporter.rb:23:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.5/lib/rails/rack/logger.rb:38:in `call_app'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.5/lib/rails/rack/logger.rb:22:in `call'
/var/www/discourse/config/initializers/quiet_logger.rb:10:in `call_with_quiet_assets'
/var/www/discourse/config/initializers/silence_logger.rb:26:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.5/lib/action_dispatch/middleware/request_id.rb:21:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiler.rb:193:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.5/lib/rails/engine.rb:514:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.5/lib/rails/application.rb:144:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.5/lib/rails/railtie.rb:194:in `public_send'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/railties-4.1.5/lib/rails/railtie.rb:194:in `method_missing'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:138:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:65:in `block in call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `each'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in `call'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:576:in `process_client'
/var/www/discourse/lib/middleware/unicorn_oobgc.rb:95:in `process_client'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `load'
/var/www/discourse/vendor/bundle/ruby/2.0.0/bin/unicorn:23:in `<main>'

Memory is running out and Discourse stops working
(Kane York) #2

What i learned from the email stuff is that ASCII-8BIT in Ruby is not so much of an encoding as the lack of one. Certain libraries would reset the text back to that when I passed a string through it, so I saved the encoding before and used force_encoding(prev_encoding) on the output.


(Sam Saffron) #3

Looking at the code:

   <b><a href="<%= @list.more_topics_url.sub('.json?','?') %>" rel="next"><%= t 'next_page'%></a></b>

I wonder if somehow more_topics_url is not utf8 encoded. Let’s try forcing it…

Also appears to be triggered from this line which is odd.

  <b><%= post.user.username_lower %></b> <%= "(#{post.user.name})" if SiteSetting.display_name_on_posts %> — <%= post.created_at.to_formatted_s(:iso8601) %> — #<%= post.post_number %>

(Sam Saffron) #4

Note, this still happens intermittently. 2 unicorns will be working fine and one goes into a catastrophic state, for some random reason.

Checked the strings in the DB and all are UTF8 even on the lines that fail.


(Jens Maier) #5

Hm, since it’s an ERB file, the stack trace doesn’t guarantee that the error originated from one of the ERB tags. It’d be interesting to see what part of the line _app_views_list_list_erb___19075230255371980_70047495970040 actually represents.

Maybe you could patch ActionView and have the << method catch the error and append a hexdump of the offending string to the exception message before reraising…?


(Sam Saffron) #6

In one of the examples the offending string was user.name which is crazy odd cause I iterated through the entire db column and nothing was not UTF-8

Going to have to add some fancy error handling here so we can debug it.


(Ionatan Wiznia) #7

Are you deserializing any of those strings?
There’s an unresolved bug I reported on psych Subclasses of string loses encoding by iwiznia · Pull Request #178 · ruby/psych · GitHub that can cause this error.
It’s a bit strange that you use a subclass of string, but there are a lot of libraries that do this. So, if for example the user name comes from an external source read through a library that subclasses string, this bug would only occur the first time that user is used, and then work once read from the database.
This happened to me while using the AdWords api gem, which was using another gem to make the http requests.
Fits exactly with your description and explains why you don’t see any user name on the database with the wrong encoding.
How can I reproduce this bug? I was looking forward to contribute to discourse, and this is a great excuse to do so :slight_smile:


(Sam Saffron) #8

Unfortunately the only way to reproduce this is wait a few weeks for stuff to crash :frowning: I have no particular repro steps.


(Sam Saffron) #9

With this commit we should be one step closer to resolving this.

  1. We log the problem strings
  2. We massage data so stuff no longer explodes

https://github.com/discourse/discourse/commit/090dc80f8a23dbb3ad703efbac990aa917c06505

Leaving this open while we gather more diagnostics.


(Ionatan Wiznia) #10

Please, update when yo have more info…
I think it would be useful to log the backtrace of the error to help pinpoint the problem.


(Sam Saffron) #11

All our errors have backtraces thanks to logster :slight_smile:

Will update if I have any more info


(Ionatan Wiznia) #12

Interesting gem, I’ll give it a try when I have some time.


(Dean Taylor) #13

@sam is there any chance this is related to this support issue?


(Sam Saffron) #14

Possible, check your logs


(Dean Taylor) #15

Part of the problem with blank / white page on iOS is that there was no errors in the log related to it.


(Sam Saffron) #16

So it’s not the same issue, this always shows up in logs


(Brian Ewins) #17

I was looking at this bug in the course of solving a similar one in our internal code, just want to point something out in case it helps - the order of the two encodings in the error message is important. What this is saying is that line 17 of list.erb is (correctly I presume) appending UTF-8, but that somewhere earlier in the file you’d appended an ASCII-8BIT string; the bug isn’t on line 17 unless it happened earlier in the loop, which is why forcing the encoding on that line doesn’t help.

We narrowed down our bug by adding a canary: < !-- <%= ‘Iñtërnâtiônàlizætiøn’.force_encoding(‘utf-8’) %> --> - before where the error occurred, it narrowed down which lines were introducing the 8-bit text. If it’s happening inside the loop, this canary will flip the order of the encodings in the exception.


(Sam Saffron) #20

This issue was resolved with our upgrade to pg 0.18.1 which unfortunately appears to have a memory leak.

So its back to square 1 here. We HAD to downgrade for latest beta.

cc @PJH


(Jeff Atwood) #21

Yes, every Discourse instance running out of memory in 1 day was a much more severe bug than every hundredth Discourse instance occasionally having posts that fail to render.

Should we file a memory leak bug with the pg site @sam? You’re working on repro.


(Jeff Atwood) #22