如何解决Dockerized应用程序中的Ruby on Rails错误“检测到堆栈崩溃”

ncgqoxb0  于 2023-08-03  发布在  Docker
关注(0)|答案(2)|浏览(129)

bounty已结束.回答此问题可获得+200声望奖励。赏金宽限期8小时后结束。MingMan希望引起更多关注这个问题:这个问题是我公司发布的障碍。需要一个快速的答案

在我的M2 Macbook Pro 16英寸,2023
我有一个Dockerized Rails应用程序,直到我将Mac操作系统更新到13.4.1(c)(22F770820d)。
现在,当我加载一个关于开发的页面时,我重新构建并部署的应用容器,它关闭并输出:

2023-07-24 16:03:33    (0.1ms)  SELECT pg_try_advisory_lock(3213395767516697805);
2023-07-24 16:03:33   ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"
2023-07-24 16:03:33   ActiveRecord::InternalMetadata Load (0.2ms)  SELECT  "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2  [["key", "environment"], ["LIMIT", 1]]
2023-07-24 16:03:33    (0.1ms)  BEGIN
2023-07-24 16:03:33    (0.1ms)  COMMIT
2023-07-24 16:03:33    (0.1ms)  SELECT pg_advisory_unlock(3213395767516697805)
2023-07-24 16:03:33   ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"
2023-07-24 16:03:36 *** stack smashing detected ***: /usr/local/bundle/bin/rake assets:precompile terminated
2023-07-24 16:03:36 ./entrypoint.sh: line 5:    17 Aborted                 bundle exec rake assets:precompile
2023-07-24 16:03:36 Puma starting in single mode...
2023-07-24 16:03:36 * Version 3.12.1 (ruby 2.5.1-p57), codename: Llamas in Pajamas
2023-07-24 16:03:36 * Min threads: 5, max threads: 5
2023-07-24 16:03:36 * Environment: development
2023-07-24 16:03:38 * Listening on tcp://0.0.0.0:3000
2023-07-24 16:03:38 Use Ctrl-C to stop
2023-07-24 16:03:44 Started GET "/" for 10.0.0.2 at 2023-07-24 16:03:44 -0400
2023-07-24 16:03:44 Cannot render console from 10.0.0.2! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
2023-07-24 16:03:44   ActiveRecord::SchemaMigration Load (0.6ms)  SELECT "schema_migrations".* FROM "schema_migrations"
2023-07-24 16:03:44 Processing by PagesController#splash as HTML
2023-07-24 16:03:44   Rendering pages/splash.haml within layouts/application
2023-07-24 16:03:44 *** stack smashing detected ***: puma 3.12.1 (tcp://0.0.0.0:3000) [app] terminated
2023-07-24 16:03:44 ./entrypoint.sh: line 11:    29 Aborted                 bundle exec puma -C config/puma.rb

字符串
我试着把码头工的资源提升到天文数字,但没有运气。以下是我的一些关键docker文件:
docker-compose.local.yml:

version: '3.7'
services:
  web:
    image: game-fuse_web
    build:
      context: .
      dockerfile: ./Dockerfile.web.local
    restart: always
    depends_on:
      - app
    volumes:
      - '.:/var/www/game-fuse-ast'
    ports:
      - 80:80

  db:
    image: postgres:9.6-bullseye
    env_file:
      - .env
    volumes:
      - "db:/var/lib/postgresql/data"
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=game-fuse_development
    ports:
      - "5432:5432"
    

  app:
    stdin_open: true
    tty: true
    image: game-fuse_app
    build:
      context: .
      dockerfile: ./Dockerfile.local
    command: ./entrypoint.sh
    volumes:
      - .:/app
    ports:
      - 3000:3000
    working_dir: /app
    depends_on:
      - db

    
volumes:
  db:


Dockerfile.local:

FROM ruby:2.5.1-slim

ENV TZ=America/New_York

# Allow recently archived stretch to be accessed

RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list && \
    sed -i 's/deb.debian.org/debian.osuosl.org/g' /etc/apt/sources.list && \
    sed -i 's/security.debian.org/debian.osuosl.org/g' /etc/apt/sources.list

RUN apt-get update -qq && apt-get install -y build-essential cron libpq-dev nodejs git
RUN gem install nokogiri -v 1.12.5
RUN gem install net-protocol -v 0.1.2
RUN gem install net-smtp -v 0.3.0
RUN gem install net-imap -v 0.2.2
#RUN gem install -N rails

# Set an environment variable where the Rails app is installed to inside of Docker image
ENV RAILS_ROOT /var/www/game-fuse

RUN mkdir -p $RAILS_ROOT

# Set working directory
WORKDIR $RAILS_ROOT

# Setting env up
ENV RAILS_ENV='development'
ENV RACK_ENV='development'

# Remove reliance on git:// protocol
RUN git config --global url."https://".insteadOf git://

# Adding gems
COPY Gemfile Gemfile 
COPY Gemfile.lock Gemfile.lock
COPY config ./config

# Adding project files
RUN gem install bundler -v 2.3.26

RUN bundle install --jobs 20 --retry 5 

RUN cd $RAILS_ROOT && bundle exec whenever --update-crontab


网址:entrypoint.sh

#!/bin/bash

bundle exec rake db:migrate

bundle exec rake assets:precompile

#bundle exec whenever --update-crontab

#cron

bundle exec puma -C config/puma.rb


不知道该去哪里找,在Ruby on Rails或Docker的上下文中,在互联网上没有很多关于这个错误的结果。

webghufk

webghufk1#

“检测到堆栈粉碎”是一个指示器,表明puma运行到缓冲区溢出,程序正在保护您免受数据泄漏/损坏。这可能来自编译的Puma二进制扩展,而不是来自Ruby或Rails。
3.12.1是Puma的一个非常老的版本;我建议你先更新一下。

iszxjhcz

iszxjhcz2#

错误“stack smashing detected“表示堆栈缓冲区溢出或某种形式的内存损坏。由于您已经尝试增加分配的资源,您可能需要随机检查您的docker容器中的Rails、Ruby和gem是否与更新操作系统兼容。或者你可以尝试更新Dockerfile中的Ruby/Rails/Gems

RUN apt-get update -qq && apt-get install -y build-essential cron libpq-dev nodejs git ruby-full='a.b.c'
RUN gem install rails -v 'a.b.c'
(where 'a.b.c' is the version you want)

字符串
然后执行docker-compose build并重新运行rails应用程序。

相关问题