92 Star 497 Fork 187

GVPopenEuler / bishengjdk-8

 / 详情

NativeThreadSet.java的signalAndWait函数无法返回

已完成
缺陷
创建于  
2021-01-29 15:34

发生结果: NativeThreadSet.java的signalAndWait函数无法返回(怀疑是死锁)

输入图片说明

期望结果:NativeThreadSet.java的signalAndWait正常返回

如何重现(尽量详细):[见评论]

补充说明?:

环境情况:arm64+k8s pod

  • 版本:arm64
  • 操作系统版本 (e.g. from /etc/os-release):Linux version 4.19.90-17.ky10.aarch64 (YHKYLIN-OS@localhost.localdomain) (gcc version 7.3.0 (GCC)) #1 SMP Sun Jun 28 14:27:40 CST 2020
  • 内核版本 (e.g. uname -a):Linux node6 4.19.90-17.ky10.aarch64 #1 SMP Sun Jun 28 14:27:40 CST 2020 aarch64 aarch64 aarch64 GNU/Linux
  • 其它:

评论 (11)

xinxin.guo.tdh 创建了缺陷
展开全部操作日志

Hey xinxinguotdh, Welcome to openEuler Community.
All of the projects in openEuler Community are maintained by @openeuler-ci-bot.
That means the developers can comment below every pull request or issue to trigger Bot Commands.
Please follow instructions at https://gitee.com/openeuler/community/blob/master/en/sig-infrastructure/command.md to find the details.

假装这是一个附件。
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class NioDeadlockTest {

public static void main(String[] args) throws Exception {
File tmpFile = File.createTempFile( "deadlock" , ".txt" );
try {
writeSomeText(tmpFile);

  for (int i = 1; i <= 1000; i++) {
    System.out.println( "Attempt"  + i);
    NioDeadlockTest test = new NioDeadlockTest(tmpFile);
    test.runTest();
    test.close();
  }
} finally {
  tmpFile.delete();
}

}

private static void writeSomeText(File file) throws IOException {
FileWriter fw = new FileWriter(file);
try {
for (int i = 0; i < 1024; i++) {
fw.write( "I shall never again run into a deadlock!" );
}
} finally {
fw.close();
}
}

private final RandomAccessFile raf;

private final FileChannel fc;

public NioDeadlockTest(File file)
throws FileNotFoundException
{
raf = new RandomAccessFile(file, "r" );
fc = raf.getChannel();
}

public void runTest()
throws InterruptedException
{
Thread t1 = startTestThread(1);
Thread t2 = startTestThread(2);

Thread.sleep(100);

stopThread(t1);
stopThread(t2);

}

public void close()
throws IOException
{
raf.close();
}

private void stopThread(Thread t)
throws InterruptedException
{
System.out.println( "Interrupting thread " + t.getName());
t.interrupt();
t.join(5000);
if (t.isAlive()) {
System.out.println( "Failed to stop thread " + t.getName() + " ; deadlock? " );
}
}

private Thread startTestThread(final int id) {
Thread thread = new Thread(new Runnable() {

  private final ByteBuffer bb = ByteBuffer.allocate(1024);

  @Override
  public void run() {
    System.out.println( " > "  + id);
    try {
      long pos = 0;
      while (true) {
        bb.clear();
        fc.read(bb, pos);
        pos += 1024;
        if (pos > fc.size()) {
          pos = 0;
        }
      }
    }
    catch (IOException e) {
      System.out.println(id +  " :  "  + e.getClass());
    }
    finally {
      System.out.println( " < "  + id);
    }
  }
});
thread.setName( "test thread "  + id);
thread.start();
return thread;

}
}

xinxin.guo.tdh 修改了描述
guoge 负责人设置为Noah

@xinxin.guo.tdh 你好,收到了您报告的问题,但是问题描述中的图似乎附的太小了,打开之后看不清楚,能把报错的异常栈帧发一下吗

我这边使用毕昇JDK安装指南中最新的毕昇JDK并没有复现这个问题,请问您使用的JDK版本是哪个?这是个必现/随机问题?复现大概要多久?

报错的调用栈。

"Thread-31" #45 prio=5 os_prio=0 tid=0x000000000b71f800 nid=0x266 in Object.wait() [0x0000fffce8f4c000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)

waiting on <0x0000fff578a052f8> (a sun.nio.ch.NativeThreadSet)
at sun.nio.ch.NativeThreadSet.signalAndWait(NativeThreadSet.java:101)
locked <0x0000fff578a052f8> (a sun.nio.ch.NativeThreadSet)
at sun.nio.ch.FileChannelImpl.implCloseChannel(FileChannelImpl.java:130)
at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:115)
locked <0x0000fff578a05298> (a java.lang.Object)
at org.apache.lucene.store.NIOFSDirectory$NIOFSIndexInput.close(NIOFSDirectory.java:123)
at org.apache.lucene.util.IOUtils.close(IOUtils.java:89)
at org.apache.lucene.util.IOUtils.close(IOUtils.java:76)
at org.apache.lucene.codecs.blocktree.BlockTreeTermsReader.close(BlockTreeTermsReader.java:366)
at org.apache.lucene.util.IOUtils.close(IOUtils.java:89)
at org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsReader.close(PerFieldPostingsFormat.java:342)
at org.apache.lucene.util.IOUtils.close(IOUtils.java:89)
at org.apache.lucene.util.IOUtils.close(IOUtils.java:76)
at org.apache.lucene.index.SegmentCoreReaders.decRef(SegmentCoreReaders.java:185)
at org.apache.lucene.index.SegmentReader.doClose(SegmentReader.java:192)
at org.apache.lucene.index.IndexReader.decRef(IndexReader.java:251)
at org.apache.lucene.index.StandardDirectoryReader.doClose(StandardDirectoryReader.java:371)
at org.apache.lucene.index.IndexReader.decRef(IndexReader.java:251)
at org.apache.lucene.index.IndexReader.close(IndexReader.java:401)
locked <0x0000fff578af3d80> (a org.apache.lucene.index.StandardDirectoryReader)
at org.apache.lucene.index.FilterDirectoryReader.doClose(FilterDirectoryReader.java:134)
at org.apache.lucene.index.IndexReader.decRef(IndexReader.java:251)
at org.apache.lucene.search.SearcherManager.decRef(SearcherManager

经过测试,该版本可以。
openjdk version "1.8.0_272"
OpenJDK Runtime Environment Bisheng (build 1.8.0_272-b11)
OpenJDK 64-Bit Server VM Bisheng (build 25.272-b11, mixed mode)

经过测试,该版本-随机问题,以下版本皆有此bug:jdk181, 211,212(华为定制版)

@xinxin.guo.tdh 可以发一条PR,避免后续的同学拆坑。

经过测试,该版本可以。
openjdk version "1.8.0_272"
OpenJDK Runtime Environment Bisheng (build 1.8.0_272-b11)
OpenJDK 64-Bit Server VM Bisheng (build 25.272-b11, mixed mode)

经过测试,该版本-随机问题,以下版本皆有此bug:jdk181, 211,212(华为定制版)

@xinxin.guo.tdh 我不太确定211/212的华为定制版是什么,能使用java -version打印出版本号看一下吗,毕昇JDK在2020年9月份正式开源,只发布过8u262和8u272两个版本

该现象在高版本无法复现, 并且问题提交者未进一步提供额外信息。
暂时关闭该issue, 根据需求可以重开。
谢谢。

/close

this issue is closed by: hserror.

openeuler-ci-bot 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(5)
5329419 openeuler ci bot 1632792936 5481414 jdkboy 1606288756
Java
1
https://gitee.com/openeuler/bishengjdk-8.git
git@gitee.com:openeuler/bishengjdk-8.git
openeuler
bishengjdk-8
bishengjdk-8

搜索帮助