Taritsyn / LibSassHost

.NET wrapper around the LibSass library with the ability to support a virtual file system.
Apache License 2.0
82 stars 11 forks source link

Unhandled exceptions #31

Closed redcrayonn closed 4 years ago

redcrayonn commented 5 years ago

We've started to use your extension in combination with our webapplications. So far we've managed to fix a lot of SCSS errors which we otherwise wouldn't have noticed.

But one thing seems odd to us; there's a lot of unhandled exceptions which prevent you from starting a debugging session with for example MVC .NET 4.7.1.

My questions is whether it is at all possible to catch these exceptions and pass / bubble them to the application. We already handle exceptions thrown by the sass compiler, but it seems some exceptions take place within your extension which we cannot handle. Is it at all possible to handle them one way or another?

Error: An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module. Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Reproduction:

We'd love to hear your feedback!

Taritsyn commented 5 years ago

Hello, Olaf!

Thanks for information! In the near future I will research this problem.

Taritsyn commented 5 years ago

Hello, Olaf!

I cannot reproduce this error.

You are using a modified or original version of the LibSass? Show me the full error message with stack trace.

DaveEmmerson commented 4 years ago

at LibSassHost.Helpers.MarshallingHelpers.PtrToString(IntPtr ptr) at LibSassHost.Internal.SassCompilerProxy.FillManagedContextError(SassContextBase context, Sass_Context& ctx) at LibSassHost.Internal.SassCompilerProxy.Compile(SassDataContext dataContext) at LibSassHost.SassCompiler.InnerCompile(String content, Boolean indentedSyntax, String inputPath, String outputPath, String sourceMapPath, CompilationOptions options) at LibSassHost.SassCompiler.Compile(String content, String inputPath, String outputPath, String sourceMapPath, CompilationOptions options) at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.InnerTranslate(IAsset asset, CompilationOptions sassOptions, Boolean enableNativeMinification) at BundleTransformer.SassAndScss.Translators.SassAndScssTranslator.Translate(IList1 assets) at BundleTransformer.Core.Transformers.TransformerBase.Translate(IList1 assets, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Transform(IList1 assets, BundleContext bundleContext, BundleResponse bundleResponse, VirtualPathProvider virtualPathProvider, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse, Boolean isDebugMode) at BundleTransformer.Core.Transformers.TransformerBase.Process(BundleContext bundleContext, BundleResponse bundleResponse) at System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context, String bundleContent, IEnumerable1 bundleFiles) at System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext context) at System.Web.Optimization.Bundle.GetBundleResponse(BundleContext context) at System.Web.Optimization.BundleResolver.GetBundleContents(String virtualPath) at System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1 assets) at System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat, String[] paths) at System.Web.Optimization.Styles.RenderFormat(String tagFormat, String[] paths) at System.Web.Optimization.Styles.Render(String[] paths)

LibSassHost.1.2.7 LibSassHost.Native.win-x86.1.2.7

I'm trying to track down exactly where it fails.

Taritsyn commented 4 years ago

Hello, Dave!

You have only given a stack trace. I don't see the error message itself.

DaveEmmerson commented 4 years ago

Hi

Same as the original poster:

Error: An unhandled exception of type 'System.AccessViolationException' occurred in Unknown Module. Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Thought I'd just hijack the thread seeing as it was the same issue and there was no repro possible :)

Taritsyn commented 4 years ago

@DaveEmmerson Is this error persistent?

Apparently it occurs during processing of the Sass syntax error:

…
at LibSassHost.Internal.SassCompilerProxy.FillManagedContextError(SassContextBase context, Sass_Context& ctx)
…
DaveEmmerson commented 4 years ago

Yeah, if I exclude the files with syntax errors it is fine.

With a syntax error it fails like that quite often, but sometimes I can get the actual syntax error exception first before it fails completely.

I'm trying to get a local build of the library running so I can debug, but ran out of time for today.

Taritsyn commented 4 years ago

What version of .NET are you using? Implementation of the PtrToString method just depends on it.

DaveEmmerson commented 4 years ago

What version of .NET are you using? Implementation of the PtrToString https://github.com/Taritsyn/LibSassHost/blob/df7df2fa6b83d48a643a38b44088cf22fee5bbf0/src/LibSassHost/Helpers/MarshallingHelpers.cs#L102-L139 method just depends on

I'm not at work now, but I believe the project is a. Net framework 4.6.2 one

I'll be able to double check on monday

Thanks

DaveEmmerson commented 4 years ago

Hi

Yeah, it's framework and 4.6.2 on this project.

Thanks

Taritsyn commented 4 years ago

@redcrayonn @DaveEmmerson In version 1.2.8 fixed this error. The error was at the LibSass level.

DaveEmmerson commented 4 years ago

@Taritsyn thanks! I've created some local nuget packages of the latest commit and updated my libsasshost/libsassnative/bundletransformer.sass references and it seems to be working (in my sample size of 1 error 😁 )

Taritsyn commented 4 years ago

@DaveEmmerson Why create local nuget packages? Packages are in release.

DaveEmmerson commented 4 years ago

Ah, woops.

Does https://github.com/Taritsyn/BundleTransformer/blob/64c05f32757e469edb3b2e3f7d7d63dd6c0f82d8/src/BundleTransformer.SassAndScss/BundleTransformer.SassAndScss.csproj#L31 need to be updated though?

I'm very new to LibSass (like 2 days in), so I'm not 100% on how all the bits fit together yet.

Taritsyn commented 4 years ago

There were no changes in interface of the LibSassHost library, so you can just update the LibSassHost's packages.

DaveEmmerson commented 4 years ago

👍 thanks again - works fine after a good number of parse errors.