fuse java_java中的Fuse文件系统 - JVM错误双重免费或损坏
我正在使用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错误双重免费或损坏的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java excel jxls_java
- 下一篇: fiddler自动保存mysql_Fid