This project has moved and is read-only. For the latest updates, please go here.

Sass compilation sometimes fails with native exception in 32 bit mode

Jan 8, 2016 at 11:49 PM
Sometimes (about 10% of the time) the sass compilation within my sass bundle fails with the error:

During translation of SCSS-code, readed from the file '/Styles/compiler.scss', to CSS-code error has occurred.
See more details:
Unhandled exception in native code

The sass seems to be fine, since the rest of the time it compiles without error. If I comment out all my scss code then it fails with a much lower frequency (more like 0.2% of the time). I have also tried moving all the scss to a single file and the error still occurs (again with lower frequency: 2% of the time).

I am unable to attach to the native code to try to get more details about the error or where it occured.

I am hosting in IIS with the enable 32 bit applications set to true - setting that flag to false seems to correct the issue. I'm using BundleTransformer 1.9.89 and SassAndScss 1.9.81.

I am going to find out if I can change it to run in 64 bit mode, but if there are other possibilities to fix it I might have to go with some other solution.

Anyone else have any ideas what else I could try, or how else I could gather information about the problem?
Jan 10, 2016 at 5:25 PM
Hello, Yuri!

Try to update the LibSass Host for .Net to version 0.4.2 Alpha 1.

If it does not help, then I will continue to look for the causes of error.
Jan 11, 2016 at 3:09 PM
That has fixed it!

Thanks for the quick response time!

Jan 11, 2016 at 3:18 PM
Whoops, I stand corrected. I forgot to undo my workaround before trying it. The exception still occurs.
Jan 11, 2016 at 3:21 PM
I will continue to look for the cause of error.
Jan 11, 2016 at 5:17 PM
I've determined that we can run it in 64 bit mode without issue. For now we will be proceeding with that, so there is no pressing need for a fix, but if you do work out a potential fix I'll be happy to try it out.
Jan 13, 2016 at 6:47 PM
Hello, Yuri!

Try to update the LibSass Host for .Net to version 0.4.2 Alpha 2.
Jan 14, 2016 at 4:56 PM
Edited Jan 14, 2016 at 4:57 PM
Hi Taritsyn,

I am still getting the error. What's more confusing is I'm now also getting the error in 64 bit mode (with libsasshost 0.4.1 as well). I'm not sure under what conditions I stopped getting the error.

I tried hosting it in IIS Express instead of IIS and the debugger gave some additional information:
Managed Debugging Assistant 'CallbackOnCollectedDelegate' has detected a problem in 'C:\Program Files (x86)\IIS Express\iisexpress.exe'.

Additional information: A callback was made on a garbage collected delegate of type 'LibSassHost!LibSassHost.FileManagerMarshallingProxy+FuncString::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.
Jan 18, 2016 at 9:23 AM
Additional information: A callback was made on a garbage collected delegate of type 'LibSassHost!LibSassHost.FileManagerMarshallingProxy+FuncString::Invoke'.
Thanks for information! Initially I thought, that problem is lack of unmanaged memory. But from your message I realized, that problem is untimely garbage collection.

Previously, I pinned delegates by using GCHandle.Alloc, but it didn't work. In 0.4.2 Alpha 3 version for this purpose I began to use a simple and proven way, and it looks like it has helped.
Jan 18, 2016 at 3:40 PM
No problem at all, thanks for figuring out the solution!

I've tried it for both 32 and 64 bit and haven't had a failure yet (and I double checked that I had properly removed my workaround this time).

Thanks again!
Jan 18, 2016 at 3:46 PM