sass / libsass-net

A lightweight wrapper around libsass
MIT License
94 stars 35 forks source link

System.AccessViolationException When Referenced Variable Missing #44

Closed csteele-gl closed 7 years ago

csteele-gl commented 8 years ago

I found an issue when compiling from a content string and global variable is not declared.

Here is the invalid scrubbed input string:

$color-primary :#339999; $color-secondary :#000000; @import "C:\Source Code\svn\DEV\Web\css\scss\styles.scss"

Here is the valid scrubbed input string:

$color-primary :#339999; $color-secondary :#000000; $logo-path :'http://localhost/Images/image.jpg'; @import "C:\Source Code\svn\DEV\Web\css\scss\styles.scss"

Here is the code used to execute the string:

using (SassCompiler compiler = new SassCompiler())
{
    CompilationOptions options = new CompilationOptions
    {
        IncludePaths = new List<string> {scssSourceDirectory},
        OutputStyle = OutputStyle.Compressed
    };

    CompilationResult results = compiler.Compile(content, null, null, options);
    css = results.CompiledContent;
}

Here is the exception:

System.AccessViolationException was caught
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=LibSassHost.Native-Proxy
  StackTrace:
       at LibSassHost.Native.Helpers.MarshallingHelper.custom_strdup(SByte* value)
       at LibSassHost.Native.Helpers.MarshallingHelper.UnmarshalConstString(SByte* value)
       at LibSassHost.Native.SassNativeCompiler.FillManagedContextError(SassContext context, Sass_Context* ctx)
       at LibSassHost.Native.SassNativeCompiler.Compile(SassDataContext dataContext)
       at LibSassHost.SassCompiler.Compile(String content, String inputPath, String outputPath, CompilationOptions options)...
darrenkopp commented 7 years ago

I just pushed the latest bits to nuget, can you try with those? Not sure where libsasshost namespace is coming from though.

joaope commented 7 years ago

I believe this issue is not related with libsass-net but with this one: https://github.com/Taritsyn/LibSassHost

darrenkopp commented 7 years ago

ah ok, closing then.

csteele-gl commented 7 years ago

@joaope and @darrenkopp: Sorry about that guys! I'll post over there.