-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mismatching DokanOptions #46
Comments
Updated DokanFileHandle to use ROMountInfo instead of DokanOptions Added setFileInfo method This commit led to discovery of dokan-dev#46 which leads to problems with this code.
Hi @JaniruTEC , That's weird, I have no idea how does this could happen. |
Hi @Liryna, thanks for looking into this. My own research into Dokany shows the same results. I see no reason why this could possibly happen. Judging from the way Timeout behaves my idea would be an overflow? |
Yes! Indeed this could be the reason but as we do not touch it, I cannot say where does it comes from :( |
I'm not a C++ Developer (and I therefore have no idea how to debug dokany) but I guess, I found it:
I wrote JaniruTEC@b0433ac as a test and found those bitmasks: Changing DokanOptions to use JNA's ULONG (JaniruTEC@adc12b9) fixed the problem, making both return Obviously the conversion was causing this. But I still have not idea, why on earth a bit is set at index 41 of an unsigned 32-bit int. EDIT |
Well found! This does looks to be the correct cause of the issue. Does that mean Options was also a 64bits ? This would have slide all the data from the struct. We would need to look at the struct padding and fields position to know what could have set this field. Not sure that really needed here as the reason was found now. |
Options is also a 64bit long, yes. Is it possible that wrong padding can cause JNA to read data from another field? We're not talking about a Gameboy after all. But if we are sure that this is, what's happening, then no further analysis on the issue will be needed. The dokan-java team will have to check all structs for similar problems tho. @infeo Could you verify our solution, please? |
Well this is interesting. On my computer everything works as expected without any fix, i.e. there is no magic bit "flip" in the fields of DokanOptions. I mean, the error is already anaylzed and it is clear where the problem is, but it seems like it only occurs on specific setups. @JaniruTEC What Dokan version is installed on your system? |
This could lie in the nature of this error. We can't know for sure which bits are set on which addresses; this bit could possibly come from anywhere on my computer. I use Dokan 1.3.1.1000. |
Well, then i don't think I can verify here a lot.^^ Changing the type to JNA's ULONG should solve it. Of course it decreases performance because we wrap the primitive type with an object, but JNA was never built for it in the first way. |
When implementing
DokanFileSystem#zwCreateFile
one has two objects that wrap the same native DokanOptions-Object:DokanFileSystem#dokanOptions
written on mountand
DokanFileInfo#DokanOpts
which is generated from the pointer every time the method is invoked.Tests show that those two references do indeed point to the same native address, but are out of sync. From my perspective the native object is (wrongly!) changed after mount which results in differing values that shouldn't be different.
My tests with this code (branch / JaniruTEC@8b636ca) yield the following results:
This: DeviceOptions(Version=110, ThreadCount=5, Options=138, mountOptions=EnumIntegerSet(elements=[STD_ERR_OUTPUT, WRITE_PROTECTION, CURRENT_SESSION]), GlobalContext=0, MountPoint=M:, UNCName=null, Timeout=3000, AllocationUnitSize=4096, SectorSize=512)
Parameter: DeviceOptions(Version=110, ThreadCount=5, Options=138, mountOptions=EnumIntegerSet(elements=[STD_ERR_OUTPUT, WRITE_PROTECTION, CURRENT_SESSION]), GlobalContext=0, MountPoint=M:, UNCName=null, Timeout=2199023258552, AllocationUnitSize=512, SectorSize=512)
It shows that only two fields are affected (Timeout and AllocationUnitSize). It seems that this error has it's origin in @dokan-dev/dokan-core. Maybe you guys know more.
The text was updated successfully, but these errors were encountered: