sass / libsass-net

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

Heap Corruption error on Compile #28

Closed Gerseras closed 8 years ago

Gerseras commented 9 years ago

If i use new SassCompiler().Compile(scssContent); i get an exception that the heap might be corrupted If i write my scssContent to a file and then use the CompileFile function it works flawlessly. Do you have an Idea what could be causing this?

aviatrix commented 9 years ago

Which version of the library are you using ?

darrenkopp commented 9 years ago

Can you provide the value you are passing in?

Gerseras commented 9 years ago

Sorry for my delayed response: I´m using the version x64 3.2.4.1 before that the compile function didn´t even work for me. Also i´m using this on a win 7 x64 pc with iis 7.5 if thats of any use. Here is the scss content which reproduces the issue for me.

edit: It even crashes if do something like

a {color:red;}

original source:

// Global
.slide {
    overflow: hidden;
    -webkit-transition: all 0.3s cubic-bezier(1, 1, 1, 1);
    transition: all 0.3s cubic-bezier(1, 1, 1, 1);  
    &.hidden {
        max-height: 0;
    }
    &.visible {
        max-height: 300px;/* approximate max height */
    }
}
// 1. Colors

// Primary Colors

// Orange 
$primary-color1: #ff7500;
$primary-color1-90: #ff8219; 
$primary-color1-80: #ff9033;  
$primary-color1-70: #ff9e4c;
$primary-color1-60: #ffac66;  
$primary-color1-50: #ffb97f;
$primary-color1-40: #ffc799;  
$primary-color1-30: #ffd5b2;
$primary-color1-15: #ffead8;

// Blue
$primary-color2: #16bade; 
$primary-color2-90: #2dc0e1;
$primary-color2-80: #44c7e4;
$primary-color2-70: #5ccee8;
$primary-color2-60: #73d5eb;  
$primary-color2-50: #8adcee;
$primary-color2-40: #a1e3f1;  
$primary-color2-30: #b9eaf5;
$primary-color2-15: #dcf4fa; 

$primary-color3: #ffffff;  
$primary-color4: #000000;
$primary-color5: #445056;

// Feedback Colors
$feedback-color-positive: #006600;
$feedback-color-negative: #c90707;

// Shade Colors
$shade-color-35: #a5a5a5;
$shade-color-15: #e3e3e3;
$shade-color-10: #efefef;
$shade-color-5:  #f6f6f6;

// 2. Typography

$font-stack:  CI, Arial, sans-serif;
$icon-font: "soda-icon";

//Explicitly set font-size on input-fields to prevent the auto-zoom
//http://www.jonassebastianohlsson.com/blog/2013/11/25/how-to-stop-zoom-in-on-input-focus-on-mobile-devices/
$form-field-font-size: 1.0 rem;
$form-field-padding: 45px;
// Fontsizes

$font-size-default: 1rem;

$font-size-small-10: 0.875rem;

$font-size-large-10: 1.15rem;
$font-size-large-20: 1.25rem;
$font-size-large-30: 1.5rem;
$font-size-large-40: 1.75rem;

// Sizes

$page-padding: 10px;        // The space between the website and the outermost edge

// Sidebar

// Footer
JimBobSquarePants commented 9 years ago

I'm getting the same error with v3.2.5 64bit

Unhandled exception at 0x00007FF85DF00F20 (ntdll.dll) in w3wp.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00007FF85DF3DD40).

JimBobSquarePants commented 8 years ago

Just bumping the thread to see if there are any updates to this? Unfortunately I've not been able to release some much needed updates to one of my projects as libsass-net is a dependency.

darrenkopp commented 8 years ago

The problem is in the last two FreeString statements I believe, but why those have issues in the 64-bit version but not the 32-bit version, I have no idea.

JimBobSquarePants commented 8 years ago

Bugger... I was hoping you had a quick fix. C++ is an unknown for me.

darrenkopp commented 8 years ago

while trying stuff a night ago i couldn't get anything that would work on both, but i could get something to work on 32-bit or 64-bit, so maybe i'll special case and use different methods for different bitness. c++ man... :cry:

danpetitt commented 8 years ago

Just browsing on iPad in bed so not much I can do, but I imagine somewhere it is already freeing something. To guard against this initially I would, in StringToAnsi, set p to NULL once memory was freed to ensure you don't free twice, but I would have to debug code to see what might be happening to your heap. Eg.

if (p)
{
  Marshal::FreeCoTaskMem(IntPtr((void *) p));
  p = NULL;
}
darrenkopp commented 8 years ago

Well, it'd be odd if it was only being freed up on the 64-bit version. It works on the 32-bit version

SavchukSergey commented 8 years ago

Hi, I'm getting heap corrupted error when I choose .net framework 4.5.1, 4.5.2 or 4.6 for my test project. When I select framework 4.5 everything works.

I'm using sample code

    class Program {
        static void Main(string[] args) {
            var sassCompiler = new SassCompiler();
            var result = sassCompiler.Compile("body { color:blue; }");
            System.IO.File.WriteAllText(@"d:\temp\compact.css", result);
        }
    }

Environment: Windows 10, VS2015

JimBobSquarePants commented 8 years ago

:metal:

darrenkopp commented 8 years ago

this just got deployed to nuget

JimBobSquarePants commented 8 years ago

Wizard! Well happy you got it sorted.