概述
我正在使用jnr-fuse库(https://github.com/SerCeMan/jnr-fuse)在java中编写Fuse-Filesystem,它在内部使用JNR进行本机访问。
文件系统作为Amazon S3存储桶的前端,基本上允许用户将其存储桶作为普通存储设备安装。
在重新处理我的read方法时,我遇到了以下JVM错误:
*** Error in `/usr/local/bin/jdk1.8.0_65/bin/java': double free or corruption (!prev): 0x00007f3758953d80 ***
尝试将文件从fuse-filesystem复制到本地FS时总会发生错误,通常是在第二次调用read方法时(对于第二个128kByte数据块)
cp /tmp/fusetest/benchmark/benchmarkFile.large /tmp
有问题的阅读方法是:
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
LOGGER.debug("Reading file {}, offset = {}, read length = {}", path, offset, size);
S3fsNodeInfo nodeInfo;
try {
nodeInfo = this.dbHelper.getNodeInfo(S3fsPath.fromUnixPath(path));
} catch (FileNotFoundException ex) {
LOGGER.error("Read called on non-existing node: {}", path);
return -ErrorCodes.ENOENT();
}
try {
// *** important part start
InputStream is = this.s3Helper.getInputStream(nodeInfo.getPath(), offset, size);
byte[] data = new byte[is.available()];
int numRead = is.read(data, 0, (int) size);
LOGGER.debug("Got {} bytes from stream, putting to buffer", numRead);
buf.put(offset, data, 0, numRead);
return numRead;
// *** important part end
} catch (IOException ex) {
LOGGER.error("Error while reading file {}", path, ex);
return -ErrorCodes.EIO();
}
}
使用的输入流实际上是缓冲区上的ByteArrayInputStream,我用它来减少与S3的http通信。
我现在在单线程模式下运行保险丝,以避免任何与并发相关的问题。
有趣的是,我已经有一个没有进行任何内部缓存的工作版本,但其他方面与此处显示的完全相同。
不幸的是我并没有真正进入JVM内部,所以我不确定如何找到底层 - 正常的调试没有产生任何结果,因为实际错误似乎发生在C端。
这里是上述命令触发的读操作的完整控制台输出:
2016-02-29 02:08:45,652 DEBUG s3fs.fs.CacheEnabledS3fs [main] - Reading file /benchmark/benchmarkFile.large, offset = 0, read length = 131072
unique: 7, opcode: READ (15), nodeid: 3, insize: 80, pid: 8297
read[0] 131072 bytes from 0 flags: 0x8000
2016-02-29 02:08:46,024 DEBUG s3fs.fs.CachedS3Helper [main] - Getting data from cache - path = /benchmark/benchmarkFile.large, offset = 0, length = 131072
2016-02-29 02:08:46,025 DEBUG s3fs.fs.CachedS3Helper [main] - Path /benchmark/benchmarkFile.large not yet in cache, add it
2016-02-29 02:08:57,178 DEBUG s3fs.fs.CachedS3Helper [main] - Path /benchmark/benchmarkFile.large found in cache!
read[0] 131072 bytes from 0
unique: 7, success, outsize: 131088
2016-02-29 02:08:57,179 DEBUG s3fs.fs.CachedS3Helper [main] - Starting actual cache read for path /benchmark/benchmarkFile.large
2016-02-29 02:08:57,179 DEBUG s3fs.fs.CachedS3Helper [main] - Reading data from cache block 0, blockOffset = 0, length = 131072
2016-02-29 02:08:57,179 DEBUG s3fs.fs.CacheEnabledS3fs [main] - Got 131072 bytes from stream, putting to buffer
2016-02-29 02:08:57,180 DEBUG s3fs.fs.CacheEnabledS3fs [main] - Reading file /benchmark/benchmarkFile.large, offset = 131072, read length = 131072
unique: 8, opcode: READ (15), nodeid: 3, insize: 80, pid: 8297
read[0] 131072 bytes from 131072 flags: 0x8000
2016-02-29 02:08:57,570 DEBUG s3fs.fs.CachedS3Helper [main] - Getting data from cache - path = /benchmark/benchmarkFile.large, offset = 131072, length = 131072
2016-02-29 02:08:57,570 DEBUG s3fs.fs.CachedS3Helper [main] - Path /benchmark/benchmarkFile.large found in cache!
2016-02-29 02:08:57,570 DEBUG s3fs.fs.CachedS3Helper [main] - Starting actual cache read for path /benchmark/benchmarkFile.large
2016-02-29 02:08:57,571 DEBUG s3fs.fs.CachedS3Helper [main] - Reading data from cache block 0, blockOffset = 131072, length = 131072
2016-02-29 02:08:57,571 DEBUG s3fs.fs.CacheEnabledS3fs [main] - Got 131072 bytes from stream, putting to buffer
read[0] 131072 bytes from 131072
unique: 8, success, outsize: 131088
*** Error in `/usr/local/bin/jdk1.8.0_65/bin/java': double free or corruption (!prev): 0x00007fcaa8b30c80 ***
最后
以上就是从容蜜粉为你收集整理的fuse java_java中的Fuse文件系统 - JVM错误双重免费或损坏的全部内容,希望文章能够帮你解决fuse java_java中的Fuse文件系统 - JVM错误双重免费或损坏所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复