Nexus-Mods / NexusMods.App

Home of the development of the Nexus Mods App
https://nexus-mods.github.io/NexusMods.App/
GNU General Public License v3.0
935 stars 46 forks source link

Exception extracting empty file from `NxFileStore` #1783

Closed Pickysaurus closed 1 month ago

Pickysaurus commented 3 months ago

Bug Report

Summary

When installing the CP2077 mod "Car Modification Shop", and then attempting to apply it the UI hangs and/or crashes.

This may be related to files in the mod that do not have a file extension(?)

Steps to reproduce

  1. Manage Cyberpunk with a blank loadout
  2. Download this file and install it https://www.nexusmods.com/Core/Libs/Common/Widgets/DownloadPopUp?id=70591&game_id=3333
  3. Apply the loadout (see that it doesn't seem to work)
  4. Apply again and the app will crash.
  5. Remove the Car Modification Shop from the loadout and Apply, see that it no longer crashes.

What is the expected behaviour?

The app does not crash.

Other information

nexusmods.app.slim.current.log nexusmods.app.main.current.log

https://github.com/user-attachments/assets/8dd25ca6-d1a3-4196-862b-ce989544cf96

erri120 commented 3 months ago

The exception is caused by an empty file:

2024-07-17_12-39-28

@Sewer56 you might wanna take a look at this.

00:01:26.241 [ERROR] (NexusMods.App.Program) Encountered an exception published to an object with an unobserved ThrownExceptions property|System.ArgumentException: A positive capacity must be specified for a Memory Mapped File backed by an empty file.
   at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile(String path, FileMode mode, String mapName, Int64 capacity, MemoryMappedFileAccess access)
   at NexusMods.Archives.Nx.FileProviders.OutputFileProvider..ctor(String outputFolder, String relativePath, FileEntry entry)
   at NexusMods.DataModel.NxFileStore.<>c__DisplayClass7_1.<ExtractFiles>b__2(Int32 x) in /_/src/NexusMods.DataModel/NxFileStore.cs:line 182
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
Sewer56 commented 3 months ago

I know what this is.

I had to add a workaround like this in the App already, same exact issue. .NET APIs don't allow memory map of 0 sized files, unlike some native counterparts. I'll slap a workaround for it in Nx

Sewer56 commented 1 month ago

This should be fixed in 0.6.0. Been fixed a few weeks back.