发生结果: NativeThreadSet.java的signalAndWait函数无法返回(怀疑是死锁)
期望结果:NativeThreadSet.java的signalAndWait正常返回
如何重现(尽量详细):[见评论]
补充说明?:
环境情况:arm64+k8s pod
uname -a
):Linux node6 4.19.90-17.ky10.aarch64 #1 SMP Sun Jun 28 14:27:40 CST 2020 aarch64 aarch64 aarch64 GNU/LinuxHey 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 你好,收到了您报告的问题,但是问题描述中的图似乎附的太小了,打开之后看不清楚,能把报错的异常栈帧发一下吗
报错的调用栈。
"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.
登录 后才可以发表评论