Project

General

Profile

Actions

Bug #10759

closed

Socket in Windows Fails to Close Correctly (message: An operation was attempted on something that is not a socket) (fptr_finalize issue?)

Added by Creetor (Justin Miller) over 9 years ago. Updated about 9 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p551 (2014-11-13) [i386-mingw32] (I have tried it with all supported Ruby Installer versions from 1.9.3 to 2.5.1)
[ruby-core:67700]

Description

Hello,

Summary:
With current versions of Ruby from the Ruby Installer (Windows 7 and Win Server 2008 R2), I will frequently (without exact recreate steps), either have my Rails app freeze or show a stack trace with an error message 'An operation was attempted on something that is not a socket.'. I have tried everything I can think of/search for to resolve this issue without success. On Ruby 2.1.5, I received a stack trace that included '@ fptr_finalize'. Grepping for that, I found that the issue is likely coming from the underlying C code, but I do not have sufficient time nor training to continue to pry at this issue without support.

Full Details:
I have been having a serious issue where my Rails app will randomly (read: many different possible stack traces, no consistent recreate steps) stop processing requests in Windows 7 and Windows Servers 2008 R2 (64bit both). I know this did not happen when I first started the project a year ago, but I am not sure when it started. I have tried several different versions of the Ruby Installer that will work with the Rails version (Ruby 1.9.3-p551, Ruby 2.0.0-p598, Ruby 2.1.5, Ruby 2.1.5 (x64), Ruby 1.9.3-p484) as well as upgrading and downgrading the various gems in the project. The issue will happen either with a SQLite3 or Postgres backend (I have not tried MySQL due to personal preference and setup time needed). The reason I believe this is Ruby related instead of Rails related, is because when I was on a higher version of Ruby, I managed to get the following Rails error screen:
Errno::ENOTSOCK in TaskStepsController#new
An operation was attempted on something that is not a socket. @ fptr_finalize - C:/dev/devops/Deployment/TAU/config/settings.yml

Rails.root: C:/dev/devops/Deployment/TAU

Application Trace | Framework Trace | Full Trace
rails_config (0.4.2) lib/rails_config/sources/yaml_source.rb:17:in read' rails_config (0.4.2) lib/rails_config/sources/yaml_source.rb:17:in load'
rails_config (0.4.2) lib/rails_config/options.rb:40:in block in reload!' rails_config (0.4.2) lib/rails_config/options.rb:39:in each'
rails_config (0.4.2) lib/rails_config/options.rb:39:in reload!' rails_config (0.4.2) lib/rails_config.rb:44:in reload!'
rails_config (0.4.2) lib/rails_config/integration/rails.rb:32:in block (3 levels) in <class:Railtie>' activesupport (4.2.0) lib/active_support/callbacks.rb:441:in instance_exec'
activesupport (4.2.0) lib/active_support/callbacks.rb:441:in block in make_lambda' activesupport (4.2.0) lib/active_support/callbacks.rb:163:in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:163:in block in halting' activesupport (4.2.0) lib/active_support/callbacks.rb:169:in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in block in halting' activesupport (4.2.0) lib/active_support/callbacks.rb:92:in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in _run_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:734:in _run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in block in instrument' activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in instrument' actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in process_action' activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in process' actionview (4.2.0) lib/action_view/rendering.rb:30:in process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in dispatch' actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in block in action' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in dispatch' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in block in serve' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in serve' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in call'
rack (1.6.0) lib/rack/etag.rb:24:in call' rack (1.6.0) lib/rack/conditionalget.rb:25:in call'
rack (1.6.0) lib/rack/head.rb:13:in call' actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in call' rack (1.6.0) lib/rack/session/abstract/id.rb:225:in context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in call' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.2.0) lib/active_support/callbacks.rb:88:in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in _run_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:734:in _run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in call'
actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in call_app' railties (4.2.0) lib/rails/rack/logger.rb:20:in block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in block in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in tagged' railties (4.2.0) lib/rails/rack/logger.rb:20:in call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in call' rack (1.6.0) lib/rack/methodoverride.rb:22:in call'
rack (1.6.0) lib/rack/runtime.rb:18:in call' activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call'
rack (1.6.0) lib/rack/lock.rb:17:in call' actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in call'
rack (1.6.0) lib/rack/sendfile.rb:113:in call' railties (4.2.0) lib/rails/engine.rb:518:in call'
railties (4.2.0) lib/rails/application.rb:164:in call' rack (1.6.0) lib/rack/content_length.rb:15:in call'
thin (1.6.3) lib/thin/connection.rb:86:in block in pre_process' thin (1.6.3) lib/thin/connection.rb:84:in catch'
thin (1.6.3) lib/thin/connection.rb:84:in pre_process' thin (1.6.3) lib/thin/connection.rb:53:in process'
thin (1.6.3) lib/thin/connection.rb:39:in receive_data' eventmachine (1.0.4) lib/eventmachine.rb:187:in run_machine'
eventmachine (1.0.4) lib/eventmachine.rb:187:in run' thin (1.6.3) lib/thin/backends/base.rb:73:in start'
thin (1.6.3) lib/thin/server.rb:162:in start' rack (1.6.0) lib/rack/handler/thin.rb:19:in run'
rack (1.6.0) lib/rack/server.rb:286:in start' railties (4.2.0) lib/rails/commands/server.rb:80:in start'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:80:in block in server' railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in tap'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in server' railties (4.2.0) lib/rails/commands/commands_tasks.rb:39:in run_command!'
railties (4.2.0) lib/rails/commands.rb:17:in <top (required)>' script/rails:6:in require'
script/rails:6:in `'

When I grepped for 'fptr_finalize', I found that it is a C function. I have found various sites/forums with various solutions, none of which have worked. The most interesting item I found was 'https://bugs.ruby-lang.org/issues/4558' which spoke about a socket close difference between Linux and Windows. I do not have the knowledge necessary to build Ruby on Windows nor do I have the C background to adjust the IO.c file.

This issue has been plaguing me for weeks. I would love to know what is going. While the app will be running on Debian 7, worker scripts will be running on Windows and I am afraid of this happening with the workers.

The Gemfile that I am currently using is (sorry for the number of gems, the utility is a task automation tool that has to interface with several systems):
source 'https://rubygems.org'

core gem needed for rails

gem 'rails', '4.2.0'

Adds bootstrap, a CSS framework from Twitter

gem 'bootstrap-sass', '3.3.1.0'

Strong encryption for password hashing and other items

gem 'bcrypt-ruby', '3.1.5'

Pagination system for list pages

gem 'will_paginate', '3.0.7'

Addin to bootstrap for styling paginate

gem 'bootstrap-will_paginate', '0.0.10'

Supports sqlite3 as the backend DB

gem 'sqlite3', '1.3.10'

Adds jquery support

gem 'jquery-rails', '4.0.3'

UI widgets like tooltips

gem 'jquery-ui-rails', '5.0.3'

Production Ruby server

gem 'thin', '1.6.3'

Needed by Thin

gem 'dalli', '2.7.2'

Needed to use postgresql as backend

gem 'pg', '0.18.1'

Connector for SQL Server

gem 'tiny_tds', '0.6.2'

Wrapper for tiny_tds that support parameters

gem 'sequel', '4.18.0'

SOAP client. Used to interact with the F5

gem 'savon', '2.8.1'

Adds support for custom configs

gem 'rails_config', '0.4.2'

Makes JS work for specs tests and steps

gem 'selenium-webdriver', '2.44.0'

LDAP client for alternate user verification

gem 'net-ldap', '0.10.1'

Adds support for sytactically awsome style sheets to the asset pipeline

gem 'sass-rails', '5.0.1'

Adds coffee script (improved, Rubyesk language that compiles into javascript)

support to the asset pipeline

gem 'coffee-rails', '4.1.0'

Helps to minify javascript

gem 'uglifier', '2.7.0'

WARNING: Don't update to latest. Savon needs httpi which needs this gem at 0.3.2

Explicitly including it because NTLM auth is valid for the app

gem 'rubyntlm', '0.3.2'

Needed for the FTP work

gem 'net-sftp', '2.1.2'

If you cannot use the cookie store (4k max), then make sure this is included

gem 'activerecord-session_store', '0.1.0'

case RUBY_PLATFORM

when /darwin/ #MAC

gem 'foo'

when /linux/

Javascript runtime needed by non-windows

gem 'therubyracer', '0.12.1'
when /mingw|mswin|win32/i

Windows only additional need for rails 4.(0-1) for timezones

gem 'tzinfo-data', '1.2014.10'
end

Items needed in development and test mode (not production)

group :test, :development do

Allows for Ruby 1.9 to be debugged (https://github.com/cldwalker/debugger)

gem 'debugger', '1.6.8'

Allows for Ruby 2.X to be debugged (https://github.com/deivid-rodriguez/byebug)

gem 'byebug', '3.5.1'

end

group :test do

Unit test framework

gem 'rspec-rails', '3.1.0'

Integration test framework

gem 'capybara', '2.4.4'

Simplifies data creation for integration tests

gem 'factory_girl_rails', '4.5.0'

Simplifies database maintenance for integration tests

gem 'database_cleaner', '1.4.0'

Static code security analysis (brakeman -o C:\dev\tau_brakeman_report.html)

gem 'brakeman'

Static code quality analysis

(rubocop --rails --format clang --out C:\dev\tau_rubocop_report.txt)

gem 'rubocop'

Code coverage utility that can combine multiple test sets

This will automatically run and place results in TAU\coverage\index.html

gem 'simplecov'
end

Thank you,
Justin

Updated by Creetor (Justin Miller) about 9 years ago

Hello,

Please close this ticket. Source of the issue was with EventMachine 1.0.4 (a dependency of Thin). There is a suggested code fix for the gem @:
https://github.com/ryuta-kai/eventmachine/commit/a0022964e549efaa2a6535055583762970fbc064#diff-179dc6925b1f78fb7bd055e8ff4e5b43

I had trouble getting that to work, so I just added EventMachine version 1.0.3 to my Gemfile and that appears to have fixed the issue completely (Thin only needs major version 1).

Thank you,
Justin

Updated by usa (Usaku NAKAMURA) about 9 years ago

  • Status changed from Open to Third Party's Issue
Actions

Also available in: Atom PDF

Like0
Like0Like0