[转帖]JVM在SUSE下奔溃的原因

jvm,suse,原因 · 浏览次数 : 0

小编点评

**问题** * Java的InetAddressImpl的getLocalHostName方法是native的,是本地系统的一个实现。它是依赖系统库来完成主机名,在大多数的linux系统中,都是以/etc/hosts中的配置来查找主机的,但在suse中却用/etc/hosts文件中的配置做主机名,所以会出现问题。 **解决方案** 在/etc/hosts中加入ip名与主机名的映射即可。 **文章知识点与官方知识档案匹配,可进一步学习相关知识Java技能树首页概览95910 人正在系统学习中** **归纳总结** * Java的InetAddressImpl的getLocalHostName方法是native的,是本地系统的一个实现。它是依赖系统库来完成主机名,在大多数的linux系统中,都是以/etc/hosts中的配置来查找主机的,但在suse中却用/etc/hosts文件中的配置做主机名,所以会出现问题。 * 解决方案:在/etc/hosts中加入ip名与主机名的映射即可。 **其他** * 问题解决文章中提到的方法在SUSE环境中可能失效,因为SUSE没有与/etc/hosts文件相同的配置。 * 问题解决文章中提到的方法可能在某些版本的Linux系统中失效,因为SUSE在使用/etc/hosts文件时可能对/etc/hosts文件进行修改。

正文

      今天同事去厂商部署项目的时候发现项目启动一会便会奔溃,但是项目已经在其他的厂商和自己公司的云服务器上稳定运行了很长时间,且经过了大量严格的功能、并发测试,这让我有些诧异,通过了了解,知道了对方机器的操作系统为SUSE,同事发回了jvm奔溃时生成的hs_err_pid文件。通过查看hs_err_pid文件,发现以下信息较为关键。

Stack: [0x00007f823bcfd000,0x00007f823bdfe000],  sp=0x00007f823bdf7a90,  free space=1002k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libresolv.so.2+0x7e7d]  __libc_res_nquery+0x4dd
C  [libresolv.so.2+0x816d]  __libc_res_nquerydomain+0xcd

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j java.net.Inet6AddressImpl.lookupAllHostAddr(Ljava/lang/String😉[Ljava/net/InetAddress;+0
j java.net.InetAddress\(<span class="hljs-number">1</span>.lookupAllHostAddr(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;)[Ljava<span class="hljs-operator">/</span>net<span class="hljs-operator">/</span>InetAddress;<span class="hljs-operator">+</span><span class="hljs-number">4</span> <span class="hljs-comment">j jav</span>a.net.InetAddress.getAddressesFromNameService(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;Ljava<span class="hljs-operator">/</span>net<span class="hljs-operator">/</span>InetAddress;)[Ljava<span class="hljs-operator">/</span>net<span class="hljs-operator">/</span>InetAddress;<span class="hljs-operator">+</span><span class="hljs-number">51</span> <span class="hljs-comment">j jav</span>a.net.InetAddress.getLocalHost()Ljava<span class="hljs-operator">/</span>net<span class="hljs-operator">/</span>InetAddress;<span class="hljs-operator">+</span><span class="hljs-number">90</span> <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.uid.UidUtils.generateVmId()Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;<span class="hljs-operator">+</span><span class="hljs-number">30</span> <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.uid.UidUtils.<span class="hljs-operator">&lt;</span>clinit<span class="hljs-operator">&gt;</span>()V<span class="hljs-operator">+</span><span class="hljs-number">9</span> <span class="hljs-comment">v </span>~StubRoutines<span class="hljs-operator">::</span><span class="hljs-keyword">call</span>_stub <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.c<span class="hljs-number">3</span>p<span class="hljs-number">0</span>.impl.C<span class="hljs-number">3</span>P<span class="hljs-number">0</span>ImplUtils.<span class="hljs-operator">&lt;</span>clinit<span class="hljs-operator">&gt;</span>()V<span class="hljs-operator">+</span><span class="hljs-number">77</span> <span class="hljs-comment">v </span>~StubRoutines<span class="hljs-operator">::</span><span class="hljs-keyword">call</span>_stub <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.c<span class="hljs-number">3</span>p<span class="hljs-number">0</span>.impl.DriverManagerDataSourceBase.<span class="hljs-operator">&lt;</span>init<span class="hljs-operator">&gt;</span>(Z)V<span class="hljs-operator">+</span><span class="hljs-number">69</span> <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.c<span class="hljs-number">3</span>p<span class="hljs-number">0</span>.DriverManagerDataSource.<span class="hljs-operator">&lt;</span>init<span class="hljs-operator">&gt;</span>(Z)V<span class="hljs-operator">+</span><span class="hljs-number">2</span> <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.c<span class="hljs-number">3</span>p<span class="hljs-number">0</span>.DriverManagerDataSource.<span class="hljs-operator">&lt;</span>init<span class="hljs-operator">&gt;</span>()V<span class="hljs-operator">+</span><span class="hljs-number">2</span> <span class="hljs-comment">j com</span>.mchange.v<span class="hljs-number">2</span>.c<span class="hljs-number">3</span>p<span class="hljs-number">0</span>.DataSources.unpooledDataSource(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;Ljava<span class="hljs-operator">/</span>util<span class="hljs-operator">/</span>Properties;)Ljavax<span class="hljs-operator">/</span>sql<span class="hljs-operator">/</span>DataSource;<span class="hljs-operator">+</span><span class="hljs-number">4</span> <span class="hljs-comment">j org</span>.hibernate.c<span class="hljs-number">3</span>p<span class="hljs-number">0</span>.internal.C<span class="hljs-number">3</span>P<span class="hljs-number">0</span>ConnectionProvider.configure(Ljava<span class="hljs-operator">/</span>util<span class="hljs-operator">/</span>Map;)V<span class="hljs-operator">+</span><span class="hljs-number">414</span> <span class="hljs-comment">j org</span>.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>spi<span class="hljs-operator">/</span>ServiceBinding;)V<span class="hljs-operator">+</span><span class="hljs-number">24</span> <span class="hljs-comment">j org</span>.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>spi<span class="hljs-operator">/</span>ServiceBinding;)Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>Service;<span class="hljs-operator">+</span><span class="hljs-number">55</span> <span class="hljs-comment">j org</span>.hibernate.service.internal.AbstractServiceRegistryImpl.getService(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Class</span>;)Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>Service;<span class="hljs-operator">+</span><span class="hljs-number">30</span> <span class="hljs-comment">j org</span>.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(Ljava<span class="hljs-operator">/</span>util<span class="hljs-operator">/</span>Map;)Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>engine<span class="hljs-operator">/</span>jdbc<span class="hljs-operator">/</span>spi<span class="hljs-operator">/</span>JdbcConnectionAccess;<span class="hljs-operator">+</span><span class="hljs-number">20</span> <span class="hljs-comment">j org</span>.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(Ljava<span class="hljs-operator">/</span>util<span class="hljs-operator">/</span>Map;)V<span class="hljs-operator">+</span><span class="hljs-number">2</span> <span class="hljs-comment">j org</span>.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>spi<span class="hljs-operator">/</span>ServiceBinding;)V<span class="hljs-operator">+</span><span class="hljs-number">24</span> <span class="hljs-comment">j org</span>.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>spi<span class="hljs-operator">/</span>ServiceBinding;)Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>Service;<span class="hljs-operator">+</span><span class="hljs-number">55</span> <span class="hljs-comment">j org</span>.hibernate.service.internal.AbstractServiceRegistryImpl.getService(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Class</span>;)Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>Service;<span class="hljs-operator">+</span><span class="hljs-number">30</span> <span class="hljs-comment">j org</span>.hibernate.cfg.<span class="hljs-keyword">Configuration</span>.buildTypeRegistrations(Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>ServiceRegistry;)V<span class="hljs-operator">+</span><span class="hljs-number">13</span> <span class="hljs-comment">j org</span>.hibernate.cfg.<span class="hljs-keyword">Configuration</span>.buildSessionFactory(Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>service<span class="hljs-operator">/</span>ServiceRegistry;)Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>SessionFactory;<span class="hljs-operator">+</span><span class="hljs-number">17</span> <span class="hljs-comment">j com</span>.dear.simpler.db.utils.HibernateUtil.init()V<span class="hljs-operator">+</span><span class="hljs-number">35</span> <span class="hljs-comment">j com</span>.dear.simpler.db.utils.HibernateUtil.<span class="hljs-operator">&lt;</span>clinit<span class="hljs-operator">&gt;</span>()V<span class="hljs-operator">+</span><span class="hljs-number">18</span> <span class="hljs-comment">v </span>~StubRoutines<span class="hljs-operator">::</span><span class="hljs-keyword">call</span>_stub <span class="hljs-comment">j com</span>.dear.simpler.dao.impl.BaseDaoImpl.getSession()Lorg<span class="hljs-operator">/</span>hibernate<span class="hljs-operator">/</span>Session;<span class="hljs-operator">+</span><span class="hljs-number">0</span> <span class="hljs-comment">j com</span>.dear.simpler.dao.impl.BaseDaoImpl.<span class="hljs-keyword">get</span>(Ljava<span class="hljs-operator">/</span>io<span class="hljs-operator">/</span>Serializable;)Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;<span class="hljs-operator">+</span><span class="hljs-number">8</span> <span class="hljs-comment">j com</span>.dear.simpler.dbrpc.service.SmbDBOperatorImpl.dbcache_getSpLock(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;)Lcom<span class="hljs-operator">/</span>dear<span class="hljs-operator">/</span>simpler<span class="hljs-operator">/</span>dbrpc<span class="hljs-operator">/</span>thrift<span class="hljs-operator">/</span>Response;<span class="hljs-operator">+</span><span class="hljs-number">25</span> <span class="hljs-comment">v </span>~StubRoutines<span class="hljs-operator">::</span><span class="hljs-keyword">call</span>_stub <span class="hljs-comment">j sun</span>.reflect.NativeMethodAccessorImpl.<span class="hljs-keyword">invoke</span><span class="hljs-number">0</span>(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span>reflect<span class="hljs-operator">/</span><span class="hljs-keyword">Method</span>;Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;[Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;)Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;<span class="hljs-operator">+</span><span class="hljs-number">0</span> <span class="hljs-comment">j sun</span>.reflect.NativeMethodAccessorImpl.<span class="hljs-keyword">invoke</span>(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;[Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;)Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;<span class="hljs-operator">+</span><span class="hljs-number">87</span> <span class="hljs-comment">j sun</span>.reflect.DelegatingMethodAccessorImpl.<span class="hljs-keyword">invoke</span>(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;[Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;)Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;<span class="hljs-operator">+</span><span class="hljs-number">6</span> <span class="hljs-comment">j jav</span>a.lang.reflect.<span class="hljs-keyword">Method</span>.<span class="hljs-keyword">invoke</span>(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;[Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;)Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">Object</span>;<span class="hljs-operator">+</span><span class="hljs-number">57</span> <span class="hljs-comment">j com</span>.dear.simpler.dbrpc.processor.SMBDBServiceImpl.invokeMethod(Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;Ljava<span class="hljs-operator">/</span>lang<span class="hljs-operator">/</span><span class="hljs-keyword">String</span>;)Lcom<span class="hljs-operator">/</span>dear<span class="hljs-operator">/</span>simpler<span class="hljs-operator">/</span>dbrpc<span class="hljs-operator">/</span>thrift<span class="hljs-operator">/</span>Response;<span class="hljs-operator">+</span><span class="hljs-number">44</span> <span class="hljs-comment">j com</span>.dear.simpler.dbrpc.processor.SMBDBServiceImpl.getService(Lcom<span class="hljs-operator">/</span>dear<span class="hljs-operator">/</span>simpler<span class="hljs-operator">/</span>dbrpc<span class="hljs-operator">/</span>thrift<span class="hljs-operator">/</span>Request;)Lcom<span class="hljs-operator">/</span>dear<span class="hljs-operator">/</span>simpler<span class="hljs-operator">/</span>dbrpc<span class="hljs-operator">/</span>thrift<span class="hljs-operator">/</span>Response;<span class="hljs-operator">+</span><span class="hljs-number">228</span> <span class="hljs-comment">j com</span>.dear.simpler.dbrpc.thrift.SMBDBService\)Processor\(getService.getResult(Lcom<span class="hljs-operator">/</span>dear<span class="hljs-operator">/</span>simpler<span class="hljs-operator">/</span>dbrpc<span class="hljs-operator">/</span>thrift<span class="hljs-operator">/</span>SMBDBService\)Iface;Lcom/dear/simpler/dbrpc/thrift/SMBDBService\(getService_args;)Lcom<span class="hljs-operator">/</span>dear<span class="hljs-operator">/</span>simpler<span class="hljs-operator">/</span>dbrpc<span class="hljs-operator">/</span>thrift<span class="hljs-operator">/</span>SMBDBService\)getService_result;+14
j com.dear.simpler.dbrpc.thrift.SMBDBService\(Processor\)getService.getResult(Ljava/lang/Object;Lorg/apache/thrift/TBase;)Lorg/apache/thrift/TBase;+9
j org.apache.thrift.ProcessFunction.process(ILorg/apache/thrift/protocol/TProtocol;Lorg/apache/thrift/protocol/TProtocol;Ljava/lang/Object;)V+86
j org.apache.thrift.TBaseProcessor.process(Lorg/apache/thrift/protocol/TProtocol;Lorg/apache/thrift/protocol/TProtocol;)Z+126
j org.apache.thrift.server.AbstractNonblockingServer\(FrameBuffer.<span class="hljs-keyword">invoke</span>()V<span class="hljs-operator">+</span><span class="hljs-number">77</span> <span class="hljs-comment">j org</span>.apache.thrift.server.Invocation.<span class="hljs-keyword">run</span>()V<span class="hljs-operator">+</span><span class="hljs-number">4</span> <span class="hljs-comment">j jav</span>a.util.concurrent.ThreadPoolExecutor.runWorker(Ljava<span class="hljs-operator">/</span>util<span class="hljs-operator">/</span>concurrent<span class="hljs-operator">/</span>ThreadPoolExecutor\)Worker;)V+95
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub



通过观察,觉得问题应该就出现在java.net.Inet6AddressImpl.lookupAllHostAddr(Ljava/lang/String;)[Ljava/net/InetAddress;+0的地方,于是开始google 这个方法在SUSE中的问题,看看有没有人其他人遇到过。发现了这个有用信息:

The problem is that the method InetAddress.getLocalHost() does not work in SUSE environment for due to following reason. Wso2ESB uses this method.

SUSE ignores the /etc/resolv.conf but only looks at the /etc/hosts file (where you hadn't specified anything besides localhost)

http://stackoverflow.com/questions/1881546/inetaddress-getlocalhost-throws-unknownhostexception



原来,Java的InetAddressImpl的getLocalHostName的方法是native的,是本地系统的一个实现。它是依赖系统库来完成主机名,在大多数的linux系统中,都是以/etc/hosts中的配置来查找主机的,但在suse中却用/etc/hosts文件中的配置做主机名,所以会出现问题。

解决方案:在/etc/hosts中加入ip名与主机名的映射即可。问题解决



文章知识点与官方知识档案匹配,可进一步学习相关知识
Java技能树首页概览95910 人正在系统学习中

与[转帖]JVM在SUSE下奔溃的原因相似的内容:

[转帖]JVM在SUSE下奔溃的原因

今天同事去厂商部署项目的时候发现项目启动一会便会奔溃,但是项目已经在其他的厂商和自己公司的云服务器上稳定运行了很长时间,且经过了大量严格的功能、并发测试,这让我有些诧异,通过了了解,知道了对方机器的操作系统为SUSE,同事发回了jvm奔溃时生成的hs_err_pid文件。通过查看hs_err_pid

[转帖]JVM 系列 - 内存区域

一、对象在JVM中的表示: OOP-Klass模型 https://www.jianshu.com/p/424a920771a3 写的很赞。 注意:OOP-Klass是hotspot的JVM实现原理,其他JVM的实现可能不一样。、 OOP表示java实例,Klass表示class。 Klass: 包

[转帖]【JVM系列JKD8】参数参考表

JVM是Java底层核心要素,可以说Java生态的东西都是运行在JVM里面的。From:https://docs.oracle.com/javase/8/docs/ JVM参数的含义 JVM参数说明 参数名称含义默认值-Xms初始堆大小物理内存的1/64(<1GB)默认(MinHeapFreeRat

[转帖]JVM 运行数据区深度解析

https://my.oschina.net/jiagoushi/blog/5597878 运行数据区 字节码只是一个二进制文件存放在那里。要想在 jvm 里跑起来,先得有个运行的内存环境。 也就是我们所说的 jvm 运行时数据区。 1)运行时数据区的位置 运行时数据区是 jvm 中最为重要的部分,

[转帖]JVM(3)之垃圾回收(GC垃圾收集器+垃圾回收算法+安全点+记忆集与卡表+并发可达性分析......)

《深入理解java虚拟机》+宋红康老师+阳哥大厂面试题2总结整理 一、堆的结构组成 堆位于运行时数据区中是线程共享的。一个进程对应一个jvm实例。一个jvm实例对应一个运行时数据区。一个运行时数据区有一个堆空间。 java堆区在jvm启动的时候就被创建了,其空间大小也就被确定了(堆是jvm管理的最大

【转帖】3.JVM内存结构概述

目录 1.JVM内存结构 1.JVM内存结构 在JVM系列的第一篇文章中已经给出了JVM内存结构的简图,下面是JVM内存结构更加详细的图。 同样,JVM的内存结构可以分为上中下3层。 上层主要是类加载子系统,负责将字节码文件加载到内存中。 类加载又分为具体的三个环节,加载(loading)、链接(l

[转帖]为什么说JVM是黑盒子般存在,从Java 虚拟机原理内存开始

https://maimai.cn/article/detail?fid=1739907745&efid=ALbQzkwOvQr-0GryeUzRsw 为什么要学习 JVM 在很多 Java 程序员的开发生涯里,JVM 一直是黑盒子一般的存在,大家只知道运行 Java 程序需要依靠 JVM,千篇一律

[转帖]常用JVM虚拟机参数说明

常用JVM虚拟机参数说明 原文地址:https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html 非标准选项 参数说明-Xcomp强制JVM虚拟机在方法第一次被调用的时候就进行本地编译。-Xint强制JVM运行在解释模式。在

[转帖]JVM系列之:深入学习方法内联

在前面多篇文章中多次提到方法内联,作为编译器最重要的优化技术,该技术不仅可以消除调用本身带来的性能开销,还能够触发更多的优化。本文将带领大家对该技术一探究竟。 方法内联 方法内联指的是:在编译过程中遇到方法调用时,将目标方法的方法体纳入编译范围之中,并取代原方法调用的优化手段。 以 getter/s

[转帖]JVM系列之:深入学习方法内联

https://zhuanlan.zhihu.com/p/487044559 在前面多篇文章中多次提到方法内联,作为编译器最重要的优化技术,该技术不仅可以消除调用本身带来的性能开销,还能够触发更多的优化。本文将带领大家对该技术一探究竟。 方法内联 方法内联指的是:在编译过程中遇到方法调用时,将目标方