同时读写一个文件触发JDKbug导致服务崩溃

一、问题描述

        使用JAVA在上传文件时,由于网络卡顿造成一个上传请求导致请求了两次,且时间相差在2ms,而文件在进行保存到本地时的文件命名只精确到秒,导致两个线程操作了同一个文件引发了JDK的一个bug。

二、排查过程

首先排查tomcat的日志catalian.out,发现以下异常内容:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0x7) at pc=0x00007fae0733da82, pid=23450, tid=140385238705920
#
# JRE version: 7.0_15-b03
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libzip.so+0x4a82]  newEntry+0x62
#
# Core dump written. Default location: /home/axdoc/core or core.23450
#
# An error report file with more information is saved as:
# /home/axdoc/hs_err_pid23450.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

根据tomcat日志找到并通过分析日志hs_err_pid23450.log发现,其中出现错误如下:

e1bafd43b638af4d3c370e783ac32b9d007.jpg

Google搜一下,搜到这个bug:https://bugs.openjdk.java.net/browse/JDK-8013062

该bug与JDK的另一个bug是同一个问题(https://bugs.openjdk.java.net/browse/JDK-8156179),该问题提供了测试程序复现该问题。

注意:该问题的复现是基于jdk-7u15-linux-x64的版本,而jdk-7u80-linux-x64运行同样的代码报错略有不同,JDK8同样存在该问题

jdk7.0.15_hs_err_pid7471.log 日志内容如下:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0x7) at pc=0x00007f9f2f560a82, pid=7471, tid=140321710479104
#
# JRE version: 7.0_15-b03
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libzip.so+0x4a82]  newEntry+0x62
#
# Core dump written. Default location: /data/core or core.7471
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x00007f9f28007800):  JavaThread "main" [_thread_in_native, id=7472, stack(0x00007f9f31a51000,0x00007f9f31b52000)]

siginfo:si_signo=SIGBUS: si_errno=0, si_code=2 (BUS_ADRERR), si_addr=0x00007f9f31b5844d

Registers:
RAX=0x00007f9f28118210, RBX=0x00007f9f2801cc00, RCX=0x0000000000037fc1, RDX=0x00007f9f28118210
RSP=0x00007f9f31b50280, RBP=0x00007f9f31b502d0, RSI=0x0000000000000048, RDI=0x00007f9f28118210
R8 =0x00007f9f28000088, R9 =0x0000000000000001, R10=0x0000000000000048, R11=0x00007f9f30a18de0
R12=0x00007f9f31b58430, R13=0x00007f9f28118210, R14=0x000000001d0ed7de, R15=0x00007f9f2801cab0
RIP=0x00007f9f2f560a82, EFLAGS=0x0000000000010206, CSGSFS=0x0000000000000033, ERR=0x0000000000000004
  TRAPNO=0x000000000000000e

Top of Stack: (sp=0x00007f9f31b50280)
0x00007f9f31b50280:   0000000740e00d10 00007f9f00000000
0x00007f9f31b50290:   00007f9f2801cb80 00007f9f3095619c
0x00007f9f31b502a0:   00007f9f28118210 00007f9f2801cc00
0x00007f9f31b502b0:   00007f9f2801cab0 00007f9f2801c970
0x00007f9f31b502c0:   000000001d0ed7de 00007f9f31b50330
0x00007f9f31b502d0:   00007f9f31b50310 00007f9f2f5611c8
0x00007f9f31b502e0:   0000000f31b50310 00007f9f31b50330
0x00007f9f31b502f0:   000000000000000f 00007f9f280079d8
0x00007f9f31b50300:   00007f9f31b50330 00007f9f31b50810
0x00007f9f31b50310:   00007f9f31b50770 00007f9f2f55fffd
0x00007f9f31b50320:   01007f9f31b50400 00007f9f2801cab0
0x00007f9f31b50330:   6f772f617461642f 007478742e646c72
0x00007f9f31b50340:   00007f9f31b50510 00007f9f31b504c8
0x00007f9f31b50350:   00007f9f31b504c8 00007f9f2c578ee3
0x00007f9f31b50360:   00007f9f31b50538 00007f9f2c579063
0x00007f9f31b50370:   00007f9f2c561410 00007f9f00000000
0x00007f9f31b50380:   00007f9f31b50580 00007f9f31b50538
0x00007f9f31b50390:   00007f9f31b50538 00007f9f2c579063
0x00007f9f31b503a0:   00007f9f2c561410 00007f9f00000000
0x00007f9f31b503b0:   00007f9f31b50580 00007f9f31b50538
0x00007f9f31b503c0:   00007f9f31b50538 00000007c20ec458
0x00007f9f31b503d0:   00007f9f2c561410 00007f9f00000000
0x00007f9f31b503e0:   00007f9f31b50580 00007f9f31b50538
0x00007f9f31b503f0:   00007f9f31b50530 00007f9f2c5788df
0x00007f9f31b50400:   00007f9f2c561410 0000000700000100
0x00007f9f31b50410:   00007f9f28007dd0 00007f9f31b503c8
0x00007f9f31b50420:   00007f9f31b50409 0000000800000001
0x00007f9f31b50430:   00ff0000ffffff00 00007f9f2c56e4a1
0x00007f9f31b50440:   00000007410ed678 0000000000000000
0x00007f9f31b50450:   00007f9f31b50538 0000000000000000
0x00007f9f31b50460:   00007f9f0000000c 0000000000000000
0x00007f9f31b50470:   00007f9f28007800 00007f9f31b50478

Instructions: (pc=0x00007f9f2f560a82)
0x00007f9f2f560a62:   00 48 c7 40 28 00 00 00 00 41 80 7f 30 00 0f 84
0x00007f9f2f560a72:   8a 02 00 00 4c 8b 63 08 4d 2b 67 28 4d 03 67 18
0x00007f9f2f560a82:   41 0f b6 5c 24 1d 41 0f b6 44 24 1c c1 e3 08 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值