richgel999 / lzham_codec

Lossless data compression codec with LZMA-like ratios but 1.5x-8x faster decompression speed, C/C++
Other
693 stars 71 forks source link

Visual Studio 2013 assert #1

Closed Muzza closed 9 years ago

Muzza commented 9 years ago

VS2010 runs fine, but VS2013 asserts during generate_codes.

The reason seems to be that in total_bits(uint v) the call to _BitScanReverse behaves differently in Visual Studio 2013 to Visual Studio 2010. When the variable v is zero, _BitScanReverse(&l, v) will set l to 0xcccccccc and return zero. In VS2010 l does not get changed and so is still zero.

As a workaround fix I changed: if (_BitScanReverse(&l, v)) { l++; }

to: if (_BitScanReverse(&l, v)) { l++; } else { l = 0; }

This gets past this error, although I've yet to fully test the rest of the lib so I don't know if there are any other issues.

richgel999 commented 9 years ago

Thanks for reporting this Muzza. I'll dig up a copy of VS2013 and repro this. (Might merge in your change right now too.)

richgel999 commented 9 years ago

I've pushed your fix.

richgel999 commented 9 years ago

I'm downloading VS 2013 Express Windows Desktop edition, hopefully that will let me test the codec without having to make an order from the MS company store.

Muzza commented 9 years ago

I'm using the free visual studio 2013 community edition: http://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx

richgel999 commented 9 years ago

I've built with 2013 and I'm testing the x64 release version on around ~49,000. I'll test x86 and debug as well.

richgel999 commented 9 years ago

I've been testing with VS 2013 all day - so far so good. I'm going to keep testing with VS 2013 and 2010 going forward from now on.