a bit technical ; nginx, passenger, 4gb seg fixup

Lets dwell into the technical world that had me captive for a couples hours, last week:

The installation of NGINX & Phusion Passenger should be very straight forward and no cause for a blog post. Except, and the fun start here, if you are compiling both from source, inside Amazon AWS, on a small EC2 instance (32 bits) and your dom0 is 64bits (no way of knowing, but most should) and Amazon gave you a slice of memory over the 4gb of normally addressable slot (small windows of opportunity, but still). How bad can it get ? Well, you will be flooded by the dreaded “4gb seg fixup” error message in your log files and your ruby process will drop to an almost standstill speed.

Your god, Google, will advice you to do stuff (which you should have already tried):

apt-get install libc6-xen

echo ‘hwcap 0 nosegneg’ > /etc/ld.so.conf.d/libc6-xen.conf ; ldconfig

mv /lib/tls /lib/tls.disabled

And this is where you will start to despair, because, of the 26 200 Google results for “4gb seg fixup“, 26 000 are either linking to a post asking the same question or answering with one of those two answers and 200 are for 4gb usb key. Neither of which will help the message to go away from your syslog and bring it back NGINX/Ruby to decent speed.

So. At this point, where you are starting to think about wiping everything and starting back from scratch (which won’t help), try this little procedure. The principle is to remove the passenger gem from your system, reinstall it (which will only download the source), modify the makefile, recompile NGINX (which in turn automatically compile the Phusion Passenger module) and take a beer while your system serve ruby pages without (systems) errors.

#> gem uninstall passenger
#> gem install passenger

We have a valid passenger gem source code in /var/lib/gems/1.8/gems/passenger-2.2.4 - version can vary and location is valid for Ubuntu/Debian, but could change on others distro. We will be modifying the optimization flags given to the compiler. Since Phusion Passenger does not accept command line argument and variables declarations, we have no other choices than to modify the rake file pre-compilation.

#> sed ‘s/EXTRA_CXXFLAGS = “-Wall #{OPTIMIZATION_FLAGS}”/EXTRA_CXXFLAGS = “-Wall -mno-tls-direct-seg-refs #{OPTIMIZATION_FLAGS}”/g’ /tmp/rakefile

#> mv /tmp/rakefile /var/lib/gems/1.8/gems/passenger-2.2.4/Rakefile

This being done, we will start an NGINX compilation process which will, in turn, start passenger-2.2.4 compilation. Using the -mno-tls-direct-seg-refs will allows us to work arround the 4gb seg fixup error.

#> CFLAGS=”-mno-tls-direct-seg-refs” CXXFLAGS=”-mno-tls-direct-seg-refs” ./configure –prefix=’/usr/local/nginx-0.7.61′ –add-module=’/var/lib/gems/1.8/gems/passenger-2.2.4/ext/nginx’ –with-http_ssl_module –with-http_stub_status_module

There you go.

128 Responses to “a bit technical ; nginx, passenger, 4gb seg fixup”

  1. scholarships May 3, 2011 at 6:14 AM #

    Paying a small cost the reverse cell phone lookup internet site provides you in addition to an intact comment whilst has only in relation to every you’ll call for while stumble on by the side of concerning who owns the phone. You’ll locate next to with reference to the felony history, their identity while well while avenue address.

  2. Nubia Doro May 3, 2011 at 7:46 AM #

    Thanks for the great post on your blog, it really gives me an insight on this topic.~`*’:

  3. Baby bed guard May 3, 2011 at 10:28 AM #

    I just added your RSS Feed on my RSS reader, it is so nice to read your blog.”`:,-

  4. PCSO Lotto Results May 3, 2011 at 10:36 AM #

    Have you already setup a fan page on Facebook ?:;`-’

  5. Philippine Lotto Result May 3, 2011 at 11:02 AM #

    I really love the way you discuss this kind of topic.~’,~~

  6. thermoplastic polymers May 3, 2011 at 4:09 PM #

    Sometimes your blog is loading slowly, better find a better host.-,”.;

  7. Philippine Lotto Results May 3, 2011 at 7:42 PM #

    Oh i really envy the way you post topics, how i wish i could write like that.-,-*;

  8. DL-Phenylalanine Dosage May 3, 2011 at 7:44 PM #

    I’m new to your blog and i really appreciate the nice posts and great layout.,”~’,

  9. Mirta Condello May 3, 2011 at 9:19 PM #

    You can increase your blog visitors by having a fan page on facebook..,.`:

  10. ectopic pregnancy symptoms May 3, 2011 at 9:53 PM #

    You can increase your blog visitors by having a fan page on facebook.;:`;.

  11. Led garden lighting May 3, 2011 at 10:42 PM #

    Man that was very entertaining and at the same time informative..~”"*

  12. Cindy Turnipseed May 3, 2011 at 11:09 PM #

    The thing i like about your blog is that you always post direct to the point info.:;””

  13. projects electronics May 3, 2011 at 11:17 PM #

    You can also put a chatbox on your blog for more interactivity among readers.-~:’”

  14. Sammy Jeune May 4, 2011 at 12:31 AM #

    You are so cool man, the post on your blogs are super great.-’~:,

  15. Cheree Francke May 4, 2011 at 1:20 AM #

    What would be your next topic next week on your blog…”~*

  16. Carmon Cabiles May 4, 2011 at 5:07 AM #

    Great blog post and nice discussion among the comments.~*–,

  17. processor fan May 4, 2011 at 5:47 AM #

    I always visit your blog everyday to read new topics..~*“

  18. PCSO Lotto Results May 4, 2011 at 6:23 AM #

    I just added your RSS Feed on my RSS reader, it is so nice to read your blog..~*~`

  19. magnesium oxide supplements May 4, 2011 at 9:30 AM #

    Only a few blogger would discuss this topic the way you do.**”~~

  20. Smoke Alarm May 4, 2011 at 10:15 AM #

    Well, another blogger already posted a topic like this.-’:~’

  21. PCSO Lotto Result May 4, 2011 at 12:09 PM #

    A blog like yours should be earning much money from adsense.,,~:.

  22. Full body pillow May 4, 2011 at 1:25 PM #

    I will invite all my friends to your blog, you really got a great blog.*.~”`

  23. Reggie Shaffstall May 4, 2011 at 2:32 PM #

    Hey, what kind of anti-spam plugin do you use for your blog..~’.`

  24. interlocking carpet tiles May 4, 2011 at 3:01 PM #

    I really love the way you discuss this kind of topic.;”:”~