Project

Profile

Help

Support #2176

closed

Unable to read link /proc/self/exe : Permission denied (errno 13)

Added by Dmitry Kruglov over 9 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
PHP API
Start date:
2014-10-12
Due date:
% Done:

0%

Estimated time:
Found in version:
0.3.1
Platforms:

Description

Hi,

I compiled saxon extension for PHP 5.5.17 (CentOS, x86_64, ZTS-enabled PHP, Apache 2.4 running apache2-mpm-event), but I get the following error when just calling new SaxonProcessor()

JET RUNTIME HAS DETECTED UNRECOVERABLE ERROR: runtime error at com/excelsior/jet/runtime/os/DynamicLibs.java:253
Unexpected OS failure: Unable to read link /proc/self/exe
: Permission denied (errno 13)
Please, contact the vendor of the application.
Extra information about error is saved in the "/tmp/jet_err_21521.txt" file.

*** glibc detected *** /usr/sbin/httpd: malloc(): memory corruption: 0x00007f6cf43692e0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x75e76)[0x7f6d2b732e76]
/lib64/libc.so.6(+0x79904)[0x7f6d2b736904]
/lib64/libc.so.6(__libc_malloc+0x71)[0x7f6d2b7376b1]
/usr/lib64/rt/jetrt/libXKRN9005.so(+0xa1e0a8)[0x7f6d166cf0a8]

Could the reason be in PHP running as libphp5-zts and not FastCGI?


Files

jet_err_21521.txt (49.5 KB) jet_err_21521.txt Dmitry Kruglov, 2014-10-13 00:42
test.c (334 Bytes) test.c O'Neil Delpratt, 2014-12-16 12:00
Actions #1

Updated by O'Neil Delpratt over 9 years ago

This looks like a file permission error. It seems like the PHP owner is different to the ower of the jet folder, therefore access right problems. Please try checking the owner of both.

Actions #2

Updated by Dmitry Kruglov over 9 years ago

PHP runs as Apache module which is running under user 'apache'.

Even if I set apache as an onwner of the whole /usr/lib/rt dir it does not help.

It seems the process cannot get its own name/pid

Actions #3

Updated by O'Neil Delpratt over 9 years ago

Interesting problem which we will have to investigate further. I have also raised the issue with the Excelsior Jet group.

Actions #4

Updated by Dmitry Kruglov over 9 years ago

Though I still can't make it working under Apache, I managed to do it under PHP CLI. However, there was one little issue.

I have a simple script to test Saxon engine:

[dmitry@srv1 ~]# cat test.php
#!/usr/bin/php
<?php
echo "Starting...".PHP_EOL;
$proc = new SaxonProcessor();
var_dump($proc);
?>

I had to copy libjvm.so to the directory one level up.

[dmitry@srv1 ~]# ./test.php
Starting...
FATAL ERROR: Unable to load /usr/lib64/rt/lib/amd64/libjava.so (libjvm.so: cannot open shared object file: No such file or directory)
JNI_CreateJavaVM() failed with result-1
[dmitry@srv1 ~]# find /usr/lib64/rt -name libjvm.so
/usr/lib64/rt/lib/amd64/jetvm/libjvm.so
[dmitry@srv1 ~]# echo $LD_LIBRARY_PATH
/usr/lib64/rt/lib/amd64
[dmitry@srv1 ~]# sudo cp /usr/lib64/rt/lib/amd64/jetvm/libjvm.so /usr/lib64/rt/lib/amd64/libjvm.so
[dmitry@srv1 ~]# ./test.php
Starting...
object(SaxonProcessor)#1 (0) {
}

Since the library is working perfectly well under CLI, I suppose the issue is related to multithreading in Apache.

My Apache runs Event MPM which can cause these problems.

Actions #5

Updated by O'Neil Delpratt over 9 years ago

The Excelsior Jet group reported back the following on the permission error:

It looks like there is a problem with file access permissions on the end-user computer.
 
Excelsior JET reads a link of "/proc/self/exe" during its work. It is a standard way to know where the 
executable file located and according to the log file the user has no permission for accessing "/proc/self/exe".
 
To verify this please ask the user to call the following command in command line:
 
"readlink /proc/self/exe"
 
It should return location of readlink utility if there are enough rights for this. For example: "/usr/bin/readlink".
Otherwise this command will execute with no output and with some error code that may be checked by " echo $?" command.
 
This is misconfiguration problem of the target system and it may affect not only Excelsior JET but other programs as well.

Please try what they have suggested and let us know if it resolves your initial issue.

For your libjvm.so error your resolution should work fine. Another approach is mentioned in the troubleshooting guide. Please see the following:

http://www.saxonica.com/saxon-c/index.xml#troubleshooting

Actions #6

Updated by Dmitry Kruglov over 9 years ago

readlink is OK

# readlink /proc/self/exe
/bin/readlink
Actions #7

Updated by O'Neil Delpratt over 9 years ago

Further questions from Excelsior Jet:

Apache web server usually runs as the special user with limited permission on the system. The main reason of this is security.
Probably, this special user (but not the user that runs the application) has not enough rights for accessing "/proc/self/exe".
 
Also,  please ask the user if SELinux is installed on the target system. SELinux provides extended permissions for 
system files and utilities, so it could be the root cause of  "Permission denied" errors.
Actions #8

Updated by Dmitry Kruglov over 9 years ago

No SELinux.

<code class="php">
<?php
echo shell_exec("readlink /proc/self/exe");
echo shell_exec("id");
echo shell_exec("ps");
?>
</code>

Output:

/bin/readlink
uid=48(apache) gid=48(apache) groups=48(apache)
  PID TTY          TIME CMD
 1525 ?        00:00:00 sh
 1526 ?        00:00:00 ps
31864 ?        00:00:41 httpd
31980 ?        00:00:14 httpd
32008 ?        00:00:39 httpd
32015 ?        00:01:11 httpd
Actions #9

Updated by Dmitry Kruglov over 9 years ago

It seems the problem is that either Excelsior Jet or Saxon/C is not compatible with thread-safe implementation of Apache (Event MPM).

# httpd -V
Server version: Apache/2.4.3 (Unix)
Server built:   Jan  7 2013 14:32:24
Server's Module Magic Number: 20120211:6
Server loaded:  APR 1.4.6, APR-UTIL 1.5.1
Compiled using: APR 1.4.6, APR-UTIL 1.5.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)

Saxon extension fails under this configuration as described above.

But if I change MPM to Prefork:

# httpd -V
Server version: Apache/2.4.3 (Unix)
Server built:   Jan  7 2013 14:32:24
Server's Module Magic Number: 20120211:6
Server loaded:  APR 1.4.6, APR-UTIL 1.5.1
Compiled using: APR 1.4.6, APR-UTIL 1.5.1
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)

then Saxon extension works fine.

Actions #10

Updated by O'Neil Delpratt over 9 years ago

Thanks for your information, which I have passed to Excelsior. They said they are currently investigating the issue and will keep me informed of its progress.

Actions #11

Updated by Lev Nazarenko over 9 years ago

Same problem with nginx + php-fpm, works well as cli and crashes as factcgi.

Actions #12

Updated by O'Neil Delpratt over 9 years ago

Hi,

Further comment from Excelsoir Jet. I have attached the c file to try out:

Please find small C example in attachment.
Could you please ask your user to compile and run the provided C example on Apache 
with both Server MPM modes: event and prefork, and tell us the results?
 
We understand that the user had already done the similar experiment with PHP example before, 
but that example uses shell_exec, so the results could be different.
Actions #13

Updated by O'Neil Delpratt over 9 years ago

  • Status changed from New to In Progress
  • Found in version set to 0.3.1
Actions #14

Updated by O'Neil Delpratt over 3 years ago

  • Description updated (diff)
  • Status changed from In Progress to Closed

Closing this bug issue. Please reopen if problem still persists and if there is no feasible workaround.

Please register to edit this issue

Also available in: Atom PDF