From the console I cannot do any operation that touches the database. I get a Segmentation fault.
.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pg-1.1.4/lib/pg.rb:56: [BUG] Segmentation fault at 0x0000000000000110
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
It is literally any operation that might need the database, including MyModel.new.
-- Control frame information -----------------------------------------------
c:0071 p:---- s:0406 e:000405 CFUNC :initialize
c:0070 p:---- s:0403 e:000402 CFUNC :new
c:0069 p:0016 s:0398 e:000397 METHOD /Users/xxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pg-1.1.4/lib/pg.rb:56
c:0068 p:0107 s:0393 e:000392 METHOD /Users/xxx/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgres
I have uninstalled and reinstalled the pg gem. And rebuilt the database. And restarted PostgreSQL.
I have seen other people reporting the problem when running under Puma, but my configuration works under Puma, fails under console!
Edit for clarity:
Yes, using bundler.
Starting the rails console either with rails c or bundle exec rails c has the same effect (segfault) with same stack trace.
Gemfile.lock has pg (1.1.4)
I re-bundled, specifying a bundle path. The stack trace now has that bundle path, so I guess by default bundler was using the rbenv path.
As per https://github.com/ged/ruby-pg/issues/291, which is linked in the comments section of the question, adding gssencmode: disable to database.yml stops segmentation faults. I've added it under development and test environment options only, as I don't use OS X in other environments:
default: &default
adapter: postgresql
development:
<<: *default
gssencmode: disable
test:
<<: *default
gssencmode: disable
gssencmode was added in Postgresql 12:
gssencmode
This option determines whether or with what priority a secure GSS TCP/IP connection will be negotiated with the server.
The underlying bug is tracked here https://www.postgresql.org/message-id/93f7379b-2e2f-db0c-980e-07ebd5de92ff%40crunchydata.com
Related
I am having a problem on my macbook pro when I run certain terminal commands. It seems to be tied to Ruby. I am on Yosemite 10.10.3.
I am using RVM for my ruby/rails stuff. Today I tried to run a 'sass watch' while working on some Foundation learning stuff. When I run the command and I get the following:
dhcp-uris-3626:foundation johndcowan$ sass --watch
ruby(3631,0x7fff7d721300) malloc: *** error for object 0x7faac2801808: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
When running the same sass --watch command on a subsequent time, I got a bit more info:
dhcp-uris-3626:foundation johndcowan$ sass --watch
[BUG] Segmentation fault
ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-darwin11.3.0]
-- control frame ----------
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP
---------------------------
-- C level backtrace information -------------------------------------------
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap: 6
I was using ruby-2.0.0-p247. I tried switching to ruby-1.9.2-p318 and running >> gem install sass. That also bombs when running sass --watch. When I switched to using ruby-1.9.3-p125 and ran gem install sass, everything works fine. Go figure.
I tried updating RVM, to no help.
I do not know how to fix the problem I am seeing and am hoping someone here can assist me.
You should re-install gem because it have native extension which usually related to correspond ruby version used during compilation of it. In some configurations (i.e. when you use vendor/bundle directory for store application gems) when you switching between ruby versions you can still use the gem installed with other ruby version.
I have a Sinatra app using Postgres via Activerecord. I'm using RVM on a Mac and a number of gems including:
activerecord
activesupport
When I run the server (thin), I get an error:
Could not load 'active_record/connection_adapters/postgresql_adapter'.
Make sure that the adapter in config/database.yml is valid. If you use
an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add
the necessary adapter gem to the Gemfile.
The adapter is set to postgresql in the config, and I've checked my RVM and paths: My Gem install path is set properly, and I can see the appropriate gems installed properly, and the specific adapter is there too, so really not sure what could be happening or how to further troubleshoot this?
Using Ruby 2.0.0-p598, activerecord and activesupport 4.1.4
--
Further debugging attempts:
ruby -v
ruby 2.0.0p598 (2014-11-13 revision 48408) [x86_64-darwin14.0.0]
which ruby
/Users/user/.rvm/rubies/ruby-2.0.0-p598/bin/ruby
gem env (relevant parts):
EXECUTABLE DIRECTORY: /Users/user/.rvm/gems/ruby-2.0.0-p598/bin
GEM PATHS:
/Users/user/.rvm/gems/ruby-2.0.0-p598
/Users/user/.rvm/gems/ruby-2.0.0-p598#global
SHELL PATH:
/Users/user/.rvm/gems/ruby-2.0.0-p598/bin
/Users/user/.rvm/gems/ruby-2.0.0-p598#global/bin
/Users/user/.rvm/rubies/ruby-2.0.0-p598/bin
ls $GEM_HOME/gems
activerecord-4.1.4
activesupport-4.1.4
Really at a loss for what else I can look into
database.yml
development:
adapter: postgresql
database: example_db
username: example_user
password: example_password
host: localhost
A next debugging step I took was to try using rvm to install a whole new version of ruby. This worked, so I used rvm to completely remove my old version of ruby with rvm remove 2.0.0-p598 and reinstall it again rvm install 2.0.0-p598.
I still have no idea what may have happened, but perhaps somehow something in the gem caches/builds were corrupted, so if anyone runs into a weird error like this where everything is in place but still doesn't work, try clearing everything with rvm and reinstalling.
I have spent the better half of today trying to resolve an issue where fusion passenger fails to process the request due to some segment fault issue within the json gem.
There have been similar posts regarding this issue, however none of the solutions have appeared to work. I have tried to clear the gems and re bundle, e.g. gemset empty, bundle install.
The interesting this about this is running rails server is ok, and running fusion-passenger stand alone is fine too, only when running under nginx do I have this issue.
/usr/local/rvm/gems/ruby-2.0.0-p481/gems/json-1.8.1/lib/json/common.rb:67: [BUG] Segmentation fault
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
Web application could not be started
An error occurred while starting up the preloader. It exited before signalling successful startup back to Phusion Passenger. Please read this article for more information about this problem.
Raw process output:
/usr/local/rvm/gems/ruby-2.0.0-p481/gems/json-1.8.1/lib/json/common.rb:67: [BUG] Segmentation fault
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
I found the issue and resolved it. ngnix was defaulting to ruby 1.9.3, a version fusion passenger has installed. I only installed one version 2.0.0 of ruby through rvm. All i had to do was set the nginx config file to the ruby wrapper and all was good. The world is once again a happy place!
passenger_ruby /usr/local/rvm/wrappers/ruby-2.0.0-p481/ruby;
I'm running Centos 6.5, apache2 and ruby 2.1.2p95 and trying to start Puma server for my sinatra app. It continues to fail giving an extremely long output but it appears the real error is:
/usr/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/therubyracer-0.11.3/v8/init.so: [BUG] Segmentation fault at 0x0000000007fc90
here's a bigger chunk of the output:
-bash-4.1$ bundle exec puma -e staging
Puma starting in single mode...
* Version 2.9.1 (ruby 2.1.2-p95), codename: Team High Five
* Min threads: 0, max threads: 16
* Environment: staging
/usr/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/therubyracer-0.11.3/v8/init.so: [BUG] Segmentation fault at 0x0000000007fc90
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0042 p:-17562721875862 s:0153 e:000152 TOP [FINISH]
c:0041 p:---- s:0151 e:000150 CFUNC :require
c:0040 p:0023 s:0147 e:000146 TOP /usr/lib/ruby/gems/2.1.0/gems/therubyracer-0.11.3/lib/v8.rb:4 [FINISH]
c:0039 p:---- s:0145 e:000144 CFUNC :require
c:0038 p:0009 s:0141 e:000140 METHOD /usr/lib/ruby/gems/2.1.0/gems/execjs-2.2.2/lib/execjs/ruby_racer_runtime.rb:97 [FINISH]
c:0037 p:---- s:0138 e:000137 IFUNC
c:0036 p:---- s:0136 e:000135 IFUNC
I was using a newer version of therubyracer, but saw a post where someone suggested rolling back and that didn't work.
It also seems like this isn't always the error I'm getting. one time it was the sass gem that failed, but this was the most often
Ok, so I did figure out how to get around this and it was a good fix for me b/c I plan on deploying Node.js projects anyhow, but as Jan Strnádek sad in the comment above, the whole issue could be avoided by installing node.js
https://www.digitalocean.com/community/tutorials/how-to-install-and-run-a-node-js-app-on-centos-6-4-64bit
I then commented out therubyracer gem and any dependencies and bundle install again and the server started right up no problem.
We're trying to get rails to talk to a sqlserver db on Azure, we install freeTDS with openssl and libiconv:
./configure --prefix=/usr/local --with-libiconv-prefix=DIR --with-openssl=DIR
make
make install
We then add tiny_TDS and activerecord-sqlserver-adapter to the gemfile:
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
$ bundle install
Configure the database:
development:
adapter: sqlserver
host: xxxxxxx.database.windows.net
mode: DBLIB
port: 1433
database: xxxxx
username: xxxxxxxx
password: x
azure: true
Run the server:
$ rails s
Everything works great up until this point, but as soon as you visit the site ruby crashes.
steven#jenny:~/irr$ rails server -p 3001
=> Booting WEBrick
=> Rails 3.0.4 application starting in development on http://0.0.0.0:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-07-24 15:37:00] INFO WEBrick 1.3.1
[2012-07-24 15:37:00] INFO ruby 1.9.2 (2012-02-14) [x86_64-linux]
[2012-07-24 15:37:00] INFO WEBrick::HTTPServer#start: pid=7586 port=3001
/home/steven/.rvm/gems/ruby-1.9.2-p318/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68: [BUG] Segmentation fault
ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]
-- control frame ----------
c:0048 p:---- s:0232 b:0232 l:000231 d:000231 CFUNC :connect
c:0047 p:0429 s:0228 b:0228 l:000227 d:000227 METHOD /home/steven/.rvm/gems/ruby-1.9.2-p318/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68
We've tried several versions of ruby: 1.9.2-p318, 1.9.2-p320, 1.9.3-p125. Same error with all of them.
This is on ubuntu 11.10 using rvm and FreeTDS-0.9.1.
Any Ideas on a workaround?
Have I made an error somewhere along the way?
Edit
Output from IRB:
require 'tiny_tds'
client = TinyTds::Client.new(:username =>'XXXXX#XXXXXXX.database.windows.net', :password => 'XXXXXXX', :host => 'XXXXXX.database.windows.net', :mode => 'DBLIB', :azure => 'true')
SystemStackError: stack level too deep from /home/martinr/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!!
It seems to be a bug with ruby itself:
/home/martinr/.rvm/gems/ruby-1.9.2-p320/gems/tiny_tds-0.5.1/lib/tiny_tds/client.rb:68: [BUG] Segmentation fault (core dumped)
You should just do a simple IRB prompt and do something like this mentioned on the TinyTDS read me.
require 'tiny_tds'
client = TinyTds::Client.new(...)
Fill in your connection params. Simple stuff like username, password, and host. Let me know how things go.
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-Azure
https://github.com/rails-sqlserver/tiny_tds#using-tinytds-with-azure
The error seems to be caused by having a username username#servername
When you remove the #severname part, ruby no longer crashes