Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Last active April 27, 2022 03:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Watson1978/0ec37694a363c64414b944ed47dd8373 to your computer and use it in GitHub Desktop.
Save Watson1978/0ec37694a363c64414b944ed47dd8373 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rmagick', '~> 4.2.5'
gem 'sorted_set'
end
require 'rmagick'
require 'sorted_set'
Magick::Image.read('sample.pdf')
FROM alpine:3.15
RUN apk add pkgconfig imagemagick imagemagick-dev imagemagick-libs
RUN apk add sqlite sqlite-dev
RUN apk add bash wget
# Install packages for building ruby
RUN apk add \
autoconf \
bison \
bzip2 \
bzip2-dev \
ca-certificates \
coreutils \
dpkg-dev dpkg \
g++ \
gcc \
gdb \
gdbm-dev \
glib-dev \
libc-dev \
libffi-dev \
libxml2-dev \
libxslt-dev \
linux-headers \
make \
ncurses-dev \
openssl \
openssl-dev \
patch \
procps \
readline-dev \
ruby \
tar \
xz \
yaml-dev \
zlib-dev
RUN wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.4.tar.gz && \
tar -xzf ruby-3.0.4.tar.gz && \
cd ruby-3.0.4 && \
CFLAGS='-O0' ./configure --disable-install-doc --disable-install-rdoc --disable-install-capi && \
make -j install
WORKDIR /opt/rmagick
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Watson1978
Copy link
Author

$ docker build -t rmagick .

$ docker run -v $(pwd):/opt/rmagick --rm -it rmagick bash
bash-5.1# gdb --args ruby ./crash.rb 
GNU gdb (GDB) 11.1
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ruby...
(gdb) r
Starting program: /usr/local/bin/ruby ./crash.rb

...

-- drop_table(:users, {:if_exists=>true})
   -> 0.0081s
-- create_table(:users, {:force=>true})
   -> 0.0009s
Run options:
  include {:focus=>true}
  exclude {:skip=>true}

All examples were filtered out; ignoring {:focus=>true}

Thread 1 "ruby" received signal SIGSEGV, Segmentation fault.
0x00007f2e6a2dc9d9 in dict_first () from /usr/local/lib/ruby/gems/3.0.0/gems/rbtree-0.4.5/lib/rbtree.so
(gdb) bt 20
#0  0x00007f2e6a2dc9d9 in dict_first () from /usr/local/lib/ruby/gems/3.0.0/gems/rbtree-0.4.5/lib/rbtree.so
#1  0x00007f2e67ade974 in ?? () from /usr/lib/libgs.so.9
#2  0x00007f2e67adebb6 in dict_resize () from /usr/lib/libgs.so.9
#3  0x00007f2e67aec4ae in ?? () from /usr/lib/libgs.so.9
#4  0x00007f2e67ae20d5 in ?? () from /usr/lib/libgs.so.9
#5  0x00007f2e67ae356b in gs_interpret () from /usr/lib/libgs.so.9
#6  0x00007f2e67ad7f2b in ?? () from /usr/lib/libgs.so.9
#7  0x00007f2e67ad834a in gs_main_init2aux () from /usr/lib/libgs.so.9
#8  0x00007f2e67ad8ce1 in gs_main_init2 () from /usr/lib/libgs.so.9
#9  0x00007f2e67ada10b in ?? () from /usr/lib/libgs.so.9
#10 0x00007f2e67ada3c5 in ?? () from /usr/lib/libgs.so.9
#11 0x00007f2e67adaaed in ?? () from /usr/lib/libgs.so.9
#12 0x00007f2e67adba50 in gs_main_init_with_args01 () from /usr/lib/libgs.so.9
#13 0x00007f2e67adbbb5 in gs_main_init_with_args () from /usr/lib/libgs.so.9
#14 0x00007f2e6b1072e0 in ?? () from /usr/lib/ImageMagick-7.1.0/modules-Q16HDRI/coders/pdf.so
#15 0x00007f2e6a7c45cc in ReadImage () from /usr/lib/libMagickCore-7.Q16HDRI.so.10
#16 0x00007f2e6a9c8687 in rd_image () from /usr/local/lib/ruby/gems/3.0.0/gems/rmagick-4.2.5/lib/RMagick2.so
#17 0x00007f2e6a9c84c8 in Image_read () from /usr/local/lib/ruby/gems/3.0.0/gems/rmagick-4.2.5/lib/RMagick2.so
#18 0x0000564a86cf5482 in call_cfunc_1 ()
#19 0x0000564a86cf6a45 in vm_call_cfunc_with_frame ()
(More stack frames follow...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment