mafintosh/fuse-bindings

Segfault with example.js when used with latest Dokany

sam0x17 opened this issue · 8 comments

This project reproduces the error with a segfault trace:

https://github.com/samkelly/flashsync_node_test

C:\Users\sam\Desktop\flashsync_node_test (master) (test@0.1.0)
λ node .
Dokan: debug mode on
Dokan: use stderr
AllocationUnitSize: 512 SectorSize: 512
device opened
filesystem mounted on Z:
mounted: Z:\ -> \Volume{d6cc17c5-1730-4085-bce7-964f1e9f5de9}
Mounted
###QueryVolumeInfo -001
GetVolumeInformation
###Create 0000
CreateFile: \
        DesiredAccess: SYNCHRONIZE
        ShareAccess: 0x0
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 33 (0x21)
getattr(/)
CreateFile status = 0
###GetFileInfo 0000
GetFileInfo: : \
getattr(/)
        result =  0
  unknown type:54
        DispatchQueryInformation result =  c000000d
###GetFileInfo 0000
GetFileInfo: : \
getattr(/)
        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###QueryVolumeInfo 0000
GetVolumeInformation
###QueryVolumeInfo 0000
GetVolumeInformation
###Cleanup 0000
Cleanup: \

###Close 0000
Close: \

###Create 0001
CreateFile: \
        DesiredAccess: FILE_READ_ATTRIBUTES
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 2097152 (0x200000)
getattr(/)
CreateFile status = 0
###GetFileInfo 0001
GetFileInfo: : \
getattr(/)
        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0001
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###Cleanup 0001
Cleanup: \

###Close 0001
Close: \

###Create 0002
CreateFile: \
        DesiredAccess: FILE_READ_ATTRIBUTES
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 2097152 (0x200000)
getattr(/)
CreateFile status = 0
###GetFileInfo 0002
GetFileInfo: : \
getattr(/)
        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0002
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###Cleanup 0002
Cleanup: \

###Close 0002
Close: \

###Create 0003
CreateFile: \
        DesiredAccess: SYNCHRONIZE|FILE_READ_ATTRIBUTES|FILE_READ_DATA
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 0 (0x0)
getattr(/)
CreateFile status = 0
###GetFileInfo 0003
GetFileInfo: : \
getattr(/)
        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0003
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0003
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###Create 0004
CreateFile: \
        DesiredAccess: SYNCHRONIZE|FILE_READ_ATTRIBUTES|FILE_READ_DATA
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 0 (0x0)
getattr(/)
CreateFile status = 0
###GetFileInfo 0004
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0004
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###Create 0005
CreateFile: \
        DesiredAccess: FILE_READ_ATTRIBUTES
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 2097152 (0x200000)
getattr(/)
CreateFile status = 0
###Create 0006
CreateFile: \desktop.ini
        DesiredAccess: FILE_GENERIC_READ
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 100 (0x64)
getattr(/desktop.ini)
CreateFile status = c0000034
###GetFileInfo 0005
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###Create 0007
CreateFile: \
        DesiredAccess: SYNCHRONIZE|FILE_READ_ATTRIBUTES|FILE_READ_DATA
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 32 (0x20)
getattr(/)
CreateFile status = 0
###Cleanup 0005
Cleanup: \

###GetFileInfo 0007
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###Close 0005
Close: \

###Create 0008
CreateFile: \
        DesiredAccess: FILE_READ_ATTRIBUTES
        ShareAccess: FILE_SHARE_DELETE|FILE_SHARE_WRITE|FILE_SHARE_READ
        Disposition: FILE_OPEN (1)
        Attributes: 0 (0x0)
        Options: 2097152 (0x200000)
getattr(/)
CreateFile status = 0
###GetFileInfo 0007
GetFileInfo: : \
getattr(/)
        result =  0
  unknown type:55
        DispatchQueryInformation result =  c000000d
###GetFileInfo 0008
GetFileInfo: : \
getattr(/)
        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###FindFiles 0007
FindFiles: \
getattr(/)
readdir(/)
PID 3344 received SIGSEGV for address: 0x6ef1d1b
SymInit: Symbol-SearchPath: '.;C:\Users\sam\Desktop\flashsync_node_test;C:\Program Files\nodejs;C:\Windows;C:\Windows\system32;SRV*C:\websymbols*http://msdl.microsoft.com/download/symbols;', symOptions: 530, UserName: 'sam'
OS-Version: 10.0.14393 () 0x100-0x1
c:\users\sam\desktop\flashsync_node_test\node_modules\segfault-handler\src\stackwalker.cpp (941): StackWalker::ShowCallstack
c:\users\sam\desktop\flashsync_node_test\node_modules\segfault-handler\src\segfault-handler.cpp (116): segfault_handler
00007FFF1234BD00 (ntdll): (filename not available): RtlInitializeCriticalSection
00007FFF1232960B (ntdll): (filename not available): RtlImageNtHeaderEx
00007FFF12389CBA (ntdll): (filename not available): KiUserExceptionDispatcher
c:\users\sam\desktop\flashsync_node_test\node_modules\fuse-bindings\fuse-bindings.cc (238): bindings_getattr
00007FFF0440228B (dokanfuse1): (filename not available): fuse_teardown
c:\users\sam\desktop\flashsync_node_test\node_modules\fuse-bindings\fuse-bindings.cc (751): bindings_set_dirs
c:\users\sam\desktop\flashsync_node_test\node_modules\fuse-bindings\fuse-bindings.cc (775): OpCallback
c:\users\sam\desktop\flashsync_node_test\node_modules\nan\nan_callbacks_12_inl.h (175): Nan::imp::FunctionCallbackWrapper
00007FF687915C0F (node): (filename not available): v8::internal::LookupIterator::Start<1>
00007FF687748EFE (node): (filename not available): v8::internal::StrDup
00007FF687747E43 (node): (filename not available): v8::internal::StrDup
00007FF687747D1B (node): (filename not available): v8::internal::StrDup
00000343961043AB ((module-name not available)): (filename not available): (function-name not available)
00000343961042E1 ((module-name not available)): (filename not available): (function-name not available)
0000001D1A8FE2A0 ((module-name not available)): (filename not available): (function-name not available)
0000000300000000 ((module-name not available)): (filename not available): (function-name not available)
00000343961042E1 ((module-name not available)): (filename not available): (function-name not available)
0000001D1A8FE2B0 ((module-name not available)): (filename not available): (function-name not available)
0000000300000000 ((module-name not available)): (filename not available): (function-name not available)
00000343961042E1 ((module-name not available)): (filename not available): (function-name not available)
0000001D1A8FE2D0 ((module-name not available)): (filename not available): (function-name not available)
0000000300000000 ((module-name not available)): (filename not available): (function-name not available)
0000001D1A8FE378 ((module-name not available)): (filename not available): (function-name not available)
0000034396286829 ((module-name not available)): (filename not available): (function-name not available)
0000002CEB982311 ((module-name not available)): (filename not available): (function-name not available)
000002705D9AEB69 ((module-name not available)): (filename not available): (function-name not available)
0000000700000000 ((module-name not available)): (filename not available): (function-name not available)
000000EE0B162601 ((module-name not available)): (filename not available): (function-name not available)
send global release for Z:

C:\Users\sam\Desktop\flashsync_node_test (master) (test@0.1.0)
λ

@mafintosh any plans to weigh in on this? based on our investigation at dokan-dev/dokany#465 (comment) it looks like this bug currently makes fuse-bindings unusable with windows, which I think is a big deal

TLDR: to avoid some Windows 10 compatibility issues, Dokany now implements readdir by performing getattr commands for each item in the directory during readdir (because apparently at a higher level windows now does this). My understanding is that fuse-bindings then crashes because it was not designed to support re-entrant / nested operations in this way, and loses track of the fuse context.

@SamKelly i'm no windows expert but if someone wants to pr a fix to help out that would be appreciated

@mafintosh this comment dokan-dev/dokany#465 (comment) outlines the exact issue (now we know, finally!). I'm going to attempt to address this by adding a stack that keeps track of the current context, but of course your input would be extremely valuable. I don't know that my fix is going to work.

@mafintosh update: I'm still having some issues with Dokany, however I have been able to get fuse-bindings 100% working with the lesser-known, but apparently more mature WinFsp project (https://github.com/billziss-gh/winfsp). I am planning on issuing a pull request soon (time permitting) that allows fuse-bindings to selectively pick up either Dokany or WinFsp based on what is installed on the host system.

What about autodetection?

@piranna that's what I'm planning on doing, but right now I don't have that implemented.

@SamKelly sounds great!

AFAIK this is now fixed with the latest commit