Piotras' blog: Archive

2008-01-01 - 2008-01-31

When you think you are drunk

Posted on 2008-01-12 11:12:16 UTC.

I haven't been writing about new features of Midgard for the last 3 weeks, but it's high time to stop write about new ones and instead write about new upcoming releases ( which I am tuning recently ). So I tested and built release packages wherever I could, including maemo scratchbox. Unfortunatelly I found python-midgard package buggy... so I took a closer look at python, and here's what I found:

ls -l /usr/bin/python*
lrwxrwxrwx  1 root root    9 Feb 11  2007 /usr/bin/python -> python2.4
-rwxr-xr-x  1 root root 3384 Jun 14  2006 /usr/bin/python2.4
-rwxr-xr-x  1 root root  119 Jun 14  2006 /usr/bin/python2.4-pyrexc

Ok, nothing unusual, right? python command is just a symlink to python2.4. Which is cool of course, isn't it?

But strace wrote weird logs so I decided to check python version:

/usr/bin/python2.4 -V
Python 2.4.2
/usr/bin/python -V
Python 2.3.4

Please, please tell me why the hell command invoked via symlink returns different version.

Suhosin Patch

Posted on 2008-01-16 10:10:03 UTC.

I have been asked to look at random segfaults which started to appear after Midgard 1.8.5 upgrade. I checked many places and was wondering what really triggers them.

Fortunatelly I was able to run Apache through gdb and was much more wondered. Backtraces pointed to ( randomly ) : xdebug, eaccelerator, php5 library itself. Even Fatal Error like "Cannot redeclare class" caused segfaults.

So, I was completely out of ideas, when I noticed this one in Apache's log file:

PHP/5.2.4-0.dotdeb.0 with Suhosin-Patch

Suhosin, the one I started to blame. And looks like I was right. Server is perfectly fine when php5 has been replaced with the one without Suhosin Patch.

I did google a bit and found how many people reported segfaults with PHP5 with Suhosin Patch. However Suhosin itself is not blamed for segfaults I think I should ask few questions:

  • If I have at least 5 extensions loaded , which one triggers segfault if Suhosin is enabled ?
  • Which one is badly written if PHP doesn't segfault without Suhosin?
  • If one extension is badly written where can I find documentation how it should be written well to work fine with Suhosin?
  • Who made detailed tests and is sure that all extensions corrupts memory? All but Suhosin ?

Memory corruption in midgard-php

Posted on 2008-01-18 10:00:11 UTC.

Just two days ago I blamed Suhosin patch, and this morning I found probably the source of the problem.

Log entry is clear:

PHP Fatal error:  Cannot instantiate abstract class \x85\xd7\xe9\x84\x1d

I found that mgd_get_object_by_guid is not aware of Zend2 (PHP5), and code "focuses" on Zend1 (PHP4). I can not say that code uses ZE1 or ZE2 API. The issue is hard to find and it's never noticed when code is being compiled.

If you need to write code for ZE1 and ZE2, keep it in mind:

ZE1: zend_class_entry *ce;
object_init_ex(return_value, ce TSRMLS_CC);

ZE2: zend_class_entry **ce;
object_init_ex(return_value, *ce TSRMLS_CC);

But when you look for class pointer you always pass (void **) &ce) as zend_hash_find parameter. So when you use ZE1 class pointer and code is being compiled against ZE2, you get no single notice or warning. And it's very easy to omit such case, especially that code itself runs almost correctly. Almost means that sometimes it fails.

I will make 1.8.6 release next week because the issue is very serious. Meantime if you used to notice random Segfaults in error.log, please change your code and use ( recommended anyway ) midgard_object_class::get_object_by_guid instead of mgd_get_object_by_guid.

When midgard_setup fails

Posted on 2008-01-22 21:17:27 UTC.

I have been multitasking a bit and talk with Jerry about erlang issues and ran new datagard in the background. Well... it's automagic setup so it's quite clever and can make few things for you. Without any needless questions.

So, what I got when I switched to terminal again?

MIDGARD SETUP: Sitewizard created host successfully. Now cleaning up... 
MIDGARD SETUP: Preferred pear package state changed ( beta ) 
MIDGARD SETUP: Reloading apache http server 
MIDGARD SETUP: Please wait... 
Warning: file_get_contents(http://ppmobile): failed to open stream: HTTP request failed! HTTP/1.0 500 Server Error
MIDGARD SETUP: ! WARNING ! : Can not request newly created host ( http://ppmobile )  
MIDGARD SETUP ERROR: Please, analyze apache server log files 
Quitting...

Nice, now I need to analyze apache's log file :) Ah, keep in mind that all these messages are much more detailed in written log file. But now I do not need it. I will use later when I miss terminal screen.

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS