# Headless running Segfault

**URL:** <https://www.ruby-forum.com/t/headless-running-segfault/215015>\
**Category:** Ruby-Gnome 2\
**Created:** [December 19, 2011, 4:32pm UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015 "2011-12-19T16:32:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 19, 2011, 4:32pm UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/1 "2011-12-19T16:32:10Z")

</div>

Hi again,

I confirm that if I have started a X server from console and then export  
DISPLAY=:0 and run the thing, it works.

Question is, why not otherwise?

🙂

2011/12/19 Chlo D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 20, 2011, 10:40am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/2 "2011-12-20T10:40:04Z")

</div>

Subject: [ruby-gnome2-devel-en] Headless running Segfault  
Date: lun 19 dic 11 04:19:54 +0100

Quoting Chlo D. ([removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)):

> That code, running on my headless (no X) server, is crashing  
> pathetically:

It is because gtk2.rb includes a call to Gtk.init.

But if you comment out that call, your script crashes when you create  
the pixmap:

Gdk-CRITICAL \*\*:IA\_\_gdk\_screen\_get\_root\_window: assertion `GDK_IS_SCREEN (screen)' failed Gdk-CRITICAL **:IA__gdk_drawable_get_depth: assertion `GDK\_IS\_DRAWABLE  
(drawable)’ failed

Apparently, the creation of a pixmap requires you to have a root  
window.

Carlo

–

- 

```
    Se la Strada e la sua Virtu' non fossero state messe da 

```

parte,

- K \* Carlo E. Prelz - [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) che bisogno ci  
sarebbe
  - 

```
          di parlare tanto di amore e di rettitudine? 

```

(Chuang-Tzu)

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 21, 2011, 9:35am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/3 "2011-12-21T09:35:27Z")

</div>

Can you just point yourself at another X server somewhere? A  
desktop/workstation?

From: Chlo D. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Monday, December 19, 2011 8:20 AM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: [ruby-gnome2-devel-en] Headless running Segfault

Hi List,

That code, running on my headless (no X) server, is crashing  
pathetically:

chloe@ayodhya:~/pdfparser$ cat test.rb

begin

require ‘gtk2’

rescue Gtk::InitError

end

require “poppler”

buf = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE\_RGB, true, 8, 1024, 768)

# copy the rendered buffer into an pixmap for further editing

map = Gdk::Pixmap.new(nil, 1024, 768, 24)

map.draw\_pixbuf(nil, buf, 0, 0, 0, 0, -1, -1, Gdk::RGB::DITHER\_NONE, 0,  
0)

Like that:

chloe@ayodhya:~/pdfparser$ ruby test.rb

test.rb: line 10

Gdk-CRITICAL \*\*:IA\_\_gdk\_screen\_get\_root\_window: assertion  
`GDK\_IS\_SCREEN (screen)’ failed

test.rb: line 10

Gdk-CRITICAL \*\*:IA\_\_gdk\_drawable\_get\_depth: assertion  
`GDK\_IS\_DRAWABLE (drawable)’ failed

Segmentation fault

I don’t like much the idea of running an X server just for running that  
piece of software but feel like I’ll have to.

Any insight?

Thanks

Chlo

This electronic communication and any attachments may contain  
confidential and proprietary  
information of DigitalGlobe, Inc. If you are not the intended recipient,  
or an agent or employee  
responsible for delivering this communication to the intended recipient,  
or if you have received  
this communication in error, please do not print, copy, retransmit,  
disseminate or  
otherwise use the information. Please indicate to the sender that you  
have received this  
communication in error, and delete the copy you received. DigitalGlobe  
reserves the  
right to monitor any electronic communication sent or received by its  
employees, agents  
or representatives.

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 21, 2011, 9:55am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/4 "2011-12-21T09:55:14Z")

</div>

Hi,

Nope this is running in a production server that is intended to run  
headless. I started a dumb X server on it, and it works but it’s not the  
best option.

2011/12/20 Grant S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 21, 2011, 10:08am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/5 "2011-12-21T10:08:14Z")

</div>

Ah, I was thinking you would still run on that machine, but just set  
DISPLAY to a machine that has an Xserver.

From: Chlo D. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, December 20, 2011 8:52 AM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: [ruby-gnome2-devel-en] Headless running Segfault

Hi,

Nope this is running in a production server that is intended to run  
headless. I started a dumb X server on it, and it works but it’s not the  
best option.

2011/12/20 Grant S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Can you just point yourself at another X server somewhere? A  
desktop/workstation?

From: Chlo D. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Monday, December 19, 2011 8:20 AM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Subject: [ruby-gnome2-devel-en] Headless running Segfault

Hi List,

That code, running on my headless (no X) server, is crashing  
pathetically:

chloe@ayodhya:~/pdfparser$ cat test.rb

begin

require ‘gtk2’

rescue Gtk::InitError

end

require “poppler”

buf = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE\_RGB, true, 8, 1024, 768)

# copy the rendered buffer into an pixmap for further editing

map = Gdk::Pixmap.new(nil, 1024, 768, 24)

map.draw\_pixbuf(nil, buf, 0, 0, 0, 0, -1, -1, Gdk::RGB::DITHER\_NONE, 0,  
0)

Like that:

chloe@ayodhya:~/pdfparser$ ruby test.rb

test.rb: line 10

Gdk-CRITICAL \*\*:IA\_\_gdk\_screen\_get\_root\_window: assertion  
`GDK\_IS\_SCREEN (screen)’ failed

test.rb: line 10

Gdk-CRITICAL \*\*:IA\_\_gdk\_drawable\_get\_depth: assertion  
`GDK\_IS\_DRAWABLE (drawable)’ failed

Segmentation fault

I don’t like much the idea of running an X server just for running that  
piece of software but feel like I’ll have to.

Any insight?

Thanks

Chlo

This electronic communication and any attachments may contain  
confidential and proprietary  
information of DigitalGlobe, Inc. If you are not the intended recipient,  
or an agent or employee  
responsible for delivering this communication to the intended recipient,  
or if you have received  
this communication in error, please do not print, copy, retransmit,  
disseminate or  
otherwise use the information. Please indicate to the sender that you  
have received this  
communication in error, and delete the copy you received. DigitalGlobe  
reserves the  
right to monitor any electronic communication sent or received by its  
employees, agents  
or representatives.

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 23, 2011, 8:32am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/6 "2011-12-23T08:32:17Z")

</div>

Hi,

In [CAH9U35myVFycG0BO=removed\_email\_address@domain.invalid](mailto:CAH9U35myVFycG0BO=removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] Headless running Segfault” on Mon, 19 Dec 2011  
16:19:54 +0100,  
Chlo D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> map = Gdk::Pixmap.new(nil, 1024, 768, 24)  
> map.draw\_pixbuf(nil, buf, 0, 0, 0, 0, -1, -1, Gdk::RGB::DITHER\_NONE, 0, 0)

Could you show your “further editing”?  
You may not need GTK+. You may be able to do “further  
editing” with cairo.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 23, 2011, 8:49am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/7 "2011-12-23T08:49:35Z")

</div>

Hi Kou, hi List

Basically I’m just saving the pixbuf as a JPEG or PNG file for  
integration  
of it on a webpage.  
Any clue how I could get that done headless? Never used Cairo directly,  
I’m  
rather used to this pixmap/pixbuf save method.

Chlo

2011/12/22 Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![SSChloSS\_DesoutterS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8491ac/32.png) [@SSChloSS\_DesoutterS](https://www.ruby-forum.com/u/SSChloSS_DesoutterS)\
**Post date:** [December 23, 2011, 9:54am UTC](https://www.ruby-forum.com/t/headless-running-segfault/215015/8 "2011-12-23T09:54:24Z")

</div>

Hi,

In [CAH9U35=removed\_email\_address@domain.invalid](mailto:CAH9U35=removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] Headless running Segfault” on Thu, 22 Dec  
2011 15:46:16 +0100,  
Chlo D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Basically I’m just saving the pixbuf as a JPEG or PNG file for integration of  
> it on a webpage.

Does it mean you want to convert a PDF to a JPEG or PNG? OK?

Here is a sample script for it:  
[ruby-gnome/poppler/sample/pdf2.rb at main · ruby-gnome/ruby-gnome · GitHub](https://github.com/ruby-gnome2/ruby-gnome2/blob/master/poppler/sample/pdf2.rb)

> Any clue how I could get that done headless? Never used Cairo directly, I’m  
> rather used to this pixmap/pixbuf save method.

You can use cairo and/or Pixbuf headless but you can’t use  
Pixmap headless.

## Thanks,

kou
