cannot restore segment prot after reloc: Permission denied

Log

2012-07-05 Create

Content

CentOS下执行java -version竟然报错:

[root@localhost etc]# java -version

Error: dl failure on line 864 Error: failed /opt/jdk1.7.0_04/jre/lib/i386/client/libjvm.so, because /opt/jdk1.7.0_04/jre/lib/i386/client/libjvm.so: cannot restore segment prot after reloc: Permission denied

一开始以为是32bit/64bit版本不对,后来查了一下,原来是SELinux的问题。执行执行:/usr/sbin/setenforce 0 就好了。

解决办法有很多

  1. 使用chcon 命令 示例: chcon -t texrel_shlib_t /usr/local/rsi/idl_6.1/bin/bin.linux.x86/*.so
  2. 禁止掉SELinux 更改/etc/sysconfig/selinux 文件的内容为 SELINUX=disabled

Ref

  1. Linux下执行程序时发生错误: cannot restore segment prot after reloc: Permission denied
  2. 动态链接库加载出错:cannot restore segment prot after reloc: Permission denied
Written on July 5, 2012