lslib icon indicating copy to clipboard operation
lslib copied to clipboard

AccessViolationException

Open TanninOne opened this issue 3 years ago • 3 comments

As you may know, Vortex integrates divine.exe to read pak files (primarily to get at the meta.lsx file for BG3 mods).

At least one of our users got the following exception:

System.TypeInitializationException: The type initializer for 'LZ4.LZ4Codec' threw an exception. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at LZ4ps.LZ4Codec.LZ4_uncompress_unknownOutputSize_safe64(Byte[] src, Byte[] dst, Int32 src_0, Int32 dst_0, Int32 src_len, Int32 dst_maxlen)
   at LZ4ps.LZ4Codec.Decode64(Byte[] input, Int32 inputOffset, Int32 inputLength, Byte[] output, Int32 outputOffset, Int32 outputLength, Boolean knownOutputLength)
   at LZ4.LZ4Codec.AutoTest(ILZ4Service service)
   at LZ4.LZ4Codec.TryService[T]()
   at LZ4.LZ4Codec.InitializeLZ4s()
   at LZ4.LZ4Codec.Try(Action method)
   at LZ4.LZ4Codec..cctor()
   --- End of inner exception stack trace ---
   at LZ4.LZ4Codec.Decode(Byte[] input, Int32 inputOffset, Int32 inputLength, Byte[] output, Int32 outputOffset, Int32 outputLength, Boolean knownOutputLength)
   at LSLib.LS.PackageReader.ReadFileListV15(BinaryReader reader, Package package)
   at LSLib.LS.PackageReader.ReadPackageV16(FileStream mainStream, BinaryReader reader)
   at LSLib.LS.PackageReader.Read()
   at LSLib.LS.Packager.UncompressPackage(String packagePath, String outputPath, Func`2 filter)
   at Divine.CLI.CommandLinePackageProcessor.ExtractPackageResource(String file, String folder, Func`2 filter)
   at Divine.Program.Main(String[] args)

and a bit later:

System.TypeInitializationException: The type initializer for 'Alphaleonis.Win32.Filesystem.Path' threw an exception. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Alphaleonis.Win32.Filesystem.Path..cctor()
   --- End of inner exception stack trace ---
   at Alphaleonis.Win32.Filesystem.Path.GetRegularPathCore(String path, GetFullPathOptions options, Boolean allowEmpty)
   at Alphaleonis.Win32.Filesystem.Path.CheckInvalidPathChars(String path, Boolean checkAdditional, Boolean allowEmpty)
   at Alphaleonis.Win32.Filesystem.Path.IsPathRooted(String path, Boolean checkInvalidPathChars)
   at Divine.CLI.CommandLineActions.TryToValidatePath(String path)
   at Divine.CLI.CommandLineActions.SetUpAndValidate(CommandLineArguments args)
   at Divine.Program.Main(String[] args)

I think this was while trying to read the LvlUp.pak file from this mod: https://www.nexusmods.com/baldursgate3/mods/118 but I'm not sure. The lslib version used was 1.15.4. Not sure if this may be relevant but the user is probably russian (at least they're using the russian localization in Vortex)

TanninOne avatar Mar 16 '21 14:03 TanninOne

This seems to be some kind of internal memory corruption. Since the crash occurred in the self-test method of the LZ4 library I'd say it has something to do with the user's setup; no error should occur there ever in normal circumstances.

Norbyte avatar Mar 17 '21 16:03 Norbyte

Yeah, very possible, there was no further report of this kind of error. I thought maybe there is something suspicious in the code indicated by the backtrace (wrong buffer size being passed to native code or something) but if not this can probably be closed. Thanks for looking into it!

TanninOne avatar Mar 18 '21 07:03 TanninOne

unsure if related to the commit last week, but since i am now experiencing this issue, no matter how many full resets/restarts I do of the Vortex app / files

EDIT restarting the computer again seemed to fix it

noahm1216 avatar Nov 17 '23 01:11 noahm1216