Monday, December 6, 2010

Apache Segmentation Fault because of OCI / Zend in a non-standard environment

We are running Apache in a jailed environment in the context of a user that has no home directory, so the OCI8 client that comes with Zend segmentation faults when it tries to write diagnostic files.

By using GDB I made an educated guess that OCI8 is trying to figure out the home directory and probably crashes because there is no corresponding home directory in my /etc/passwd file.

GDB output:

Core was generated by `/usr/sbin/httpd -k start'.
Program terminated with signal 11, Segmentation fault.
#0  0x00002b6a1a5e51be in skgpgetinfo () from /usr/lib64/libclntsh.so.11.1

#0  0x00002b6a1a5e51be in skgpgetinfo () from /usr/lib64/libclntsh.so.11.1
#1  0x00002b6a1a74d89b in dbgroud_oradiag_user_dir () from /usr/lib64/libclntsh.so.11.1
#2  0x00002b6a1a74d067 in dbgrgad_get_adrbase_directory () from /usr/lib64/libclntsh.so.11.1
#3  0x00002b6a1a76b81d in kpeDbgGetInitFileParms () from /usr/lib64/libclntsh.so.11.1
#4  0x00002b6a1a76b5fe in kpeDbgGetInitFileParmsAndInitDBGC () from /usr/lib64/libclntsh.so.11.1
#5  0x00002b6a1a187c6d in nlstddd_do_alter_diag () from /usr/lib64/libclntsh.so.11.1
#6  0x00002b6a1a18594d in nlstddt_do_alter_trace () from /usr/lib64/libclntsh.so.11.1
#7  0x00002b6a1bbf699e in nlstdggo () from /usr/lib64/libclntsh.so.11.1
#8  0x00002b6a1bbf66af in nlstdgg () from /usr/lib64/libclntsh.so.11.1
#9  0x00002b6a1a23b5fb in nigini2 () from /usr/lib64/libclntsh.so.11.1
#10 0x00002b6a1a76be3c in kpeDbgGetNPDGlobal () from /usr/lib64/libclntsh.so.11.1
#11 0x00002b6a1a76bd10 in kpeDbgTLSInit () from /usr/lib64/libclntsh.so.11.1
#12 0x00002b6a1bd1c331 in kpummTLSGET1 () from /usr/lib64/libclntsh.so.11.1
#13 0x00002b6a1a76bfd3 in kpeDbgProcessInit () from /usr/lib64/libclntsh.so.11.1
#14 0x00002b6a1a76a457 in kpummpin () from /usr/lib64/libclntsh.so.11.1
#15 0x00002b6a1a0dcd13 in kpuenvcr () from /usr/lib64/libclntsh.so.11.1
#16 0x00002b6a1acfbdc1 in OCIEnvNlsCreate () from /usr/lib64/libclntsh.so.11.1
#17 0x00002b6a19a12a3b in php_oci_do_connect_ex () from /usr/local/zend/lib/php_extensions/oci8.so
#18 0x00002b6a19a12fcf in php_oci_do_connect () from /usr/local/zend/lib/php_extensions/oci8.so
#19 0x00002b6a19a23953 in zif_oci_connect () from /usr/local/zend/lib/php_extensions/oci8.so
#20 0x00002b6a131cdd69 in ?? () from /usr/local/zend/lib/apache2/libphp5.so
#21 0x00002b6a131a458e in execute () from /usr/local/zend/lib/apache2/libphp5.so
#22 0x00002b6a13180e99 in zend_execute_scripts () from /usr/local/zend/lib/apache2/libphp5.so
#23 0x00002b6a1312f7f8 in php_execute_script () from /usr/local/zend/lib/apache2/libphp5.so
#24 0x00002b6a1320887d in ?? () from /usr/local/zend/lib/apache2/libphp5.so
#25 0x00002b6a084cda4a in ap_run_handler ()
#26 0x00002b6a084d0ed8 in ap_invoke_handler ()
#27 0x00002b6a084db938 in ap_process_request ()
#28 0x00002b6a084d8b70 in ?? ()
#29 0x00002b6a084d4cd2 in ap_run_process_connection ()
#30 0x00002b6a084df789 in ?? ()
#31 0x00002b6a084dfa1a in ?? ()
#32 0x00002b6a084dfad0 in ?? ()
#33 0x00002b6a084e07bb in ap_mpm_run ()
#34 0x00002b6a084bae48 in main ()

This was fixed by disabling diagnostics in OCI by setting $ORACLE_HOME env to /tmp and then put "DIAG_ADR_ENABLED=OFF" into $ORACLE_HOME/network/admin/sqlnet.ora file.

Thursday, March 25, 2010

Installing bare bones Eclipse

If you have ever wanted Eclipse without Java, C++, PHP and so on, you can get a bare bones Eclipse here:

http://download.eclipse.org/eclipse/downloads/

To get to the download link, follow these steps:

  • Click the latest release
  • On the next page, on the left menu, click "Platform Runtime Binary"
  • Click the appropriate link for your platform

Sunday, February 21, 2010

The hunt for a Ruby and Ruby on Rails environment

I have been on a quest for a good setup for having some fun with Ruby and Ruby on Rails. The problem is that I'm an IDE-o-holic, so I need an environment that is both fast and where I feel home.

I am developing on Linux, so I will only consider applications available to me on this platform.

My research has resulted in three alternatives:
  • RadRails from Aptana
  • Eclispe with Dynamic Languages Toolkit
  • Vim/gVim
Vim/gVim:

You might ask yourself "Why vim? Isn't that a text editor?" and you'd be right. But with the right combination of plugins, and the time to learn the shortcuts, it's really powerful.

The plugins you'll want are these:
With this combo you will navigate between models, helpers, controllers and other files of interest with ease, as long as you bother to learn the shortcuts.

Eclipse with Dynamic Languages Toolkit: 

This is the pure IDE I've been looking for. It's fast, it's lightweight and it's familliar to me. To get this setup up and running you'll want these:
This setup gave me ALMOST everything I needed. I am on familiar grounds, and it is fast as hell. One problem though, there is no *.erb syntax highlighting (or coloring as Eclipse calls it). This is pretty frustrating, and I haven't been able to work around it completely.

Last but not least:

Aptana RadRails

To get this up and running, you fetch it here:
This is really a complete package, so if you want to get up and running fast, this is it. The webpage can tell you more about its features than I will bother to write here.

Personally I think RadRails is too bloated with features and it feels sluggish for my tastes. It's been a while since I tested Aptana RadRails, so things might've improved, but I feel like it needs to be mentioned in this list.

Read below why I have striked through this.

Conclusion

I ended up with a combination. I am using Eclipse with Dynamic Languages Toolkit for editing pure Ruby files, and through Eclipse I open ERB files in gVim.

This works pretty well for me. I have an environment that is lightning fast and where I get all the features from an IDE I care about.

Update 25.02.2010:
I have now tried RadRails for the past couple of days and I must really say it has improved since last time I used it. It now feels both fast and responsive, and it really does package everything I need into one neat package. I am going to try RadRails for a while now, it really does offer a lot for being free!

Friday, February 19, 2010

Using Windows Vista with Webdav / Web Folders

Using Windows Vista with Webdav proved to be a challenge.

After many hours of packetsniffing and debugging, it boils down to this:
  • Windows Vista needs to be SP1 + Hotfix or SP2 to function 100%
  • If you don't have SSL, you need to implement Digest authentication.
  • If you have a self signed SSL certificate, forget it, it will fail. I had to use a trusted CA to finally get it working.
  • In Windows 7 everything works out of the box.
The MAIN problem is that in Windows Vista and Windows 7, the Webdav implementation that comes with Windows is used. In earlier versions of Windows, the Webdav implementation that comes with Office is used, which is probably a lot more mature (Please correct me if I'm wrong).
Much kudos to this guy for writing up a good overview of the different DLL versions in different flavours of Windows. The list says Windows Vista without any service packs + the Hotfix will work, but for me I had to apply SP1 to get it to work.
For very interested folks, I have created a Webdav Compatibility Matrix you can check too.

Tuesday, January 26, 2010

How to run Firefox 3.7a in headless mode

This post is inspired by a need to get Selenium testsuites running faster. This is done on Ubuntu Linux x86_64 platform.
I will assume you have Firefox 3.7a from the daily repositories installed on your system.
First you have to get the sources for a incubator project called 'Offscreen':
  • wget http://hg.mozilla.org/incubator/offscreen/archive/tip.zip
Unzip them:
  • unzip tip.zip
Download compile configurations for Offscreen and put them in the newly created directory:
  • wget -O mozconfig https://bug446591.bugzilla.mozilla.org/attachment.cgi?id=350162
Inside the new directory, run:
  • make -f client.mk build
You might need some dependencies. Make will tell you what you are missing, I will not describe how to get the dependencies needed, except this:
  • apt-get install autoconf2.13
If everything went correctly, you should now be able to do:
  • ../obj-x86_64-unknown-linux-gnu/dist/bin/xulrunner /usr/lib/firefox-3.7a1pre/application.ini
You should now be presented with lots of output from your newly compiled Xulrunner, most notably when it stops:
  • [url = chrome://ubufox/content/startpage.html]
Congratulations, you now have your very own headless Firefox!

Friday, July 11, 2008

How to set up Zend Studio Neon with a SVN project

  1. In Zend Studio, select File -> Import
  2. Select SVN -> Projects from SVN and click 'Next'
  3. Create a new repository location to your SVN server
  4. Select the Folder you want to be the root of your project
  5. Click Finish
  6. A new dialogue should appear. Select the option to "Check out as a project configured using the New Project Wizard"
  7. Click Finish
  8. Select PHP -> PHP Project and click 'Next'
  9. Give the new project a name and set up any specific project configurations you may have. Click 'finish'.
  10. Voila!

Tuesday, July 8, 2008

How to set up Eclipse and PDT for Cola and DocShare through ECF

1. Follow the instructions to install ECF:
http://www.eclipse.org/ecf/downloads.php

2. In my example let's use gmail as a communications protocol:
  • Open the 'Communications' perspective
  • Click the icon that says 'Connect to Provider'
  • Select XMPPS
  • Input your gmail account and password
3. ECF has a limitation so that you can only use it with the default text editor and the Java editor, but we want to use it with PDT:
  • Open ../eclipse/plugins/org.eclipse.ecf.docshare_2.0.0.v20080623-0024.jar
  • Open the file plugin.xml
  • Paste in this XML:
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.php.core.phpsource.source.EditorContext">
<dynamic class="org.eclipse.ecf.internal.provisional.docshare.menu.DocShareRosterMenuContributionItem"
id="org.eclipse.ecf.docshare.php.dynamic3">
</dynamic>
</menuContribution>
</extension>
Now you should have a new menu entry in PHP editing mode that displays "Share Editor With"