Getting memory errors when I try to interact with ActiveRecord models
Im getting the following errors when I try to interact with about any model in my app.
ruby(25572,0x1d995dec0) malloc: double free for ptr 0x130011200
ruby(25572,0x1d995dec0) malloc: *** set a breakpoint in malloc_error_break to debug
I dont seem to be getting errors when using basic rails commands just trying to interact with models, here's an example:
Loading production environment (Rails 7.0.8)
irb(main):001> Time.zone.now
=> Tue, 26 Dec 2023 19:55:34.680327000 UTC +00:00
irb(main):002> SecureRandom.hex(8)
=> "750e8d097402c96a"
irb(main):003> Program.first
ruby(25696,0x1d995dec0) malloc: double free for ptr 0x115008200
ruby(25696,0x1d995dec0) malloc: *** set a breakpoint in malloc_error_break to debug
The app runs great in development. I've never seen these errors before I don't even know where to start testing.8 Replies
Project ID:
04f4c8ba-1da2-48d6-a1fb-ccf7916d1039
04f4c8ba-1da2-48d6-a1fb-ccf7916d1039
when I try to run railway run rails db:migrate I get an error which looks a little different
ruby(27769,0x1d995dec0) malloc: error for object 0x52: pointer being freed was not allocated
ruby(27769,0x1d995dec0) malloc: set a breakpoint in malloc_error_break to debug
The same command in development runs no problem.
ok after a little digging in the logs I discovered the following error:
2023-12-27 03:15:08.891 UTC [100] FATAL: no PostgreSQL user name specified in startup packet
2023-12-27 03:15:08.934 UTC [101] FATAL: no PostgreSQL user name specified in startup packet
I have this in my config/database.yml
production:
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: <%= ENV['PGDATABASE'] %>
username: <%= ENV['PGUSER'] %>
password: <%= ENV['PGPASSWORD'] %>
host: <%= ENV['PGHOST'] %>
port: <%= ENV['PGPORT'] %>
irb(main):001> ENV['PGUSER']
=> "postgres"
at this point Im not sure what to do. I feel like I have all of the credentials set correctly. Also, Im not sure why attempting to run railway run rails db:create
would return an error message about memory and the railway logs would have an entirely different error message about a username not being supplied.Same issue here 🖐️
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>
And the variable is available in the consoleI think there's an issue with the new Postgres service. Before I switched I was able to perform any migration, now I can't do anything.
Also, whats weird is that in Ruby I don't really have access to memory assignemnts. The only thing I can think of would be a gem that uses C functions.
I guess none of this really matters, the big issue in my mind is that the railway console returns a different error than the observability layer logs.
Just tested this by standing up a Linode server and deploying my app to it. No changes have been made to the app. Everything works great on the linode server, there's no memory allocation errors. Based on the portion of the picture I can see, this seems like an infrustructure issue with Railway.
I'm getting the same error. I have the same settings ans @MehdiGatbache
I'm trying to run migrations using
railway run bundle exec rake db:migrate RAILS_ENV=production DATABASE_URL="..."
I'm getting the same error running any rake task
I created a github issue for that: https://github.com/railwayapp/cli/issues/476
GitHub
Ruby crashes when running rake tasks from the CLI · Issue #476 · ra...
Description When trying to run a rake tasks in a rail project, ruby crashes with the following error message: $ railway run bin/rails user:send_birthdays_reminder ruby(59032,0x1d71c5000) malloc: do...
please, comment on it and up vote it to bring attention to the problem
This is the output that I'm getting from the observability window:
Seeing the same thing here, however it's working on my machine when I access the railway shell and use rails console, however my colleague is seeing these memalloc errors and are seeing the same error (
FATAL: no PostgreSQL user name specified in startup packet
) pop into the observability panel. Did anyone here manage to find a fix/workaround?
We're using the same version of Railway CLI, and our system environments are a match as well.