stride3d / stride3d/stride

Empty SDSL file crashes AssetCompiler

Open
#3,096 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Official Release

Version:

Platform(s):

Describe the bug
Empty sdsl file crashes AssetCompiler and gives non connected exception

>EXEC : error 2,254s: [AssetCompiler] Unhandled exception. Exception: EndOfStreamException: Unable to read beyond the end of the stream.
1>     at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
1>     at System.IO.BinaryReader.InternalRead(Span`1 buffer)
1>     at System.IO.BinaryReader.ReadInt32()
1>     at Stride.Core.Serialization.BinarySerializationReader.Serialize(Int32& value) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\core\Stride.Core\Serialization\Binary\BinarySerializationReader.cs:line 50
1>     at Stride.Core.Serialization.Contents.ChunkHeader.Read(SerializationStream stream) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\core\Stride.Core.Serialization\Serialization\Contents\ChunkHeader.cs:line 47
1>     at Stride.Core.Assets.CompilerApp.BundlePacker.GetChunkReferences(DatabaseFileProvider databaseFileProvider, ObjectId& objectId) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\BundlePacker.cs:line 308
1>     at Stride.Core.Assets.CompilerApp.BundlePacker.CollectBundle(DatabaseFileProvider databaseFileProvider, ResolvedBundle resolvedBundle, String assetUrl) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\BundlePacker.cs:line 368
1>     at Stride.Core.Assets.CompilerApp.BundlePacker.Build(Logger logger, PackageSession packageSession, Package rootPackage, String indexName, String outputDirectory, ISet`1 disableCompressionIds, Boolean useIncrementalBundles, List`1 bundleFiles) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\BundlePacker.cs:line 152
1>     at Stride.Core.Assets.CompilerApp.PackageBuilder.BuildMaster() in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\PackageBuilder.cs:line 161
1>     at Stride.Core.Assets.CompilerApp.PackageBuilder.Build() in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\PackageBuilder.cs:line 50
1>     at Stride.Core.Assets.CompilerApp.PackageBuilderApp.Run(String[] args) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\PackageBuilderApp.cs:line 285
1>  System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
1>     at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
1>     at System.IO.BinaryReader.InternalRead(Span`1 buffer)
1>     at System.IO.BinaryReader.ReadInt32()
1>     at Stride.Core.Serialization.BinarySerializationReader.Serialize(Int32& value) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\core\Stride.Core\Serialization\Binary\BinarySerializationReader.cs:line 50
1>     at Stride.Core.Serialization.Contents.ChunkHeader.Read(SerializationStream stream) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\core\Stride.Core.Serialization\Serialization\Contents\ChunkHeader.cs:line 47
1>     at Stride.Core.Assets.CompilerApp.BundlePacker.GetChunkReferences(DatabaseFileProvider databaseFileProvider, ObjectId& objectId) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\BundlePacker.cs:line 308
1>     at Stride.Core.Assets.CompilerApp.BundlePacker.CollectBundle(DatabaseFileProvider databaseFileProvider, ResolvedBundle resolvedBundle, String assetUrl) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\BundlePacker.cs:line 368
1>     at Stride.Core.Assets.CompilerApp.BundlePacker.Build(Logger logger, PackageSession packageSession, Package rootPackage, String indexName, String outputDirectory, ISet`1 disableCompressionIds, Boolean useIncrementalBundles, List`1 bundleFiles) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\BundlePacker.cs:line 152
1>     at Stride.Core.Assets.CompilerApp.PackageBuilder.BuildMaster() in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\PackageBuilder.cs:line 161
1>     at Stride.Core.Assets.CompilerApp.PackageBuilder.Build() in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\PackageBuilder.cs:line 50
1>     at Stride.Core.Assets.CompilerApp.PackageBuilderApp.Run(String[] args) in C:\BuildAgent\work\b5f46e3c4829a09e\sources\assets\Stride.Core.Assets.CompilerApp\PackageBuilderApp.cs:line 285

To Reproduce

  1. add in \Assets\ a "blabla.sdsl" file
  2. make sure its empty

Expected behavior
either

  1. asset compiler just ignores the file
  2. or gives a proper exception that the file is empty and that its clearly forbidden to have that

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with an empty Assets/blabla.sdsl file, then start at BundlePacker.GetChunkReferences and follow the call into ChunkHeader.Read shown in the stack trace. Add coverage for the empty-file case and ensure AssetCompiler either ignores the file or reports a clear empty-file error instead of an EndOfStreamException.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.