Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"string iterator not incrementable" issue with the chromaprint_decode_fingerprint() function #31

Closed
CyberSinh opened this issue Dec 12, 2016 · 7 comments

Comments

@CyberSinh
Copy link
Contributor

Hi Lukas,

I'm trying to use the chromaprint_decode_fingerprint function but I get the following error message at runtime:

Debug Assertion Failed!
Program: MSVCP140D.DLL
File: VC\include\xstring
Line: 106
Expression: string iterator not incrementable

Do you know why?

Thanks.

You will find below a sample repro:

uint32_t *fp;
int length, algorithm;

char *encoded = "AQABz9GSJEkkKYmS4Tp6xvjx-tBpXMfRpUP1w3yGHmUPcWTwhnhgiYNeeBcu5HhbxA2PZuEFnSd-9FECq-gJPbtQ_fiLfkf3wvnRl9AO__jxCj7-QjzyoFek4xcmPnA2-qjUDz9yTsR56PFRJp4GP8ePLj2qY-NRfkL2oXEx6cFThPCh7_iRVnzQbX9wHc0UT0I_5Duao1KVGOsPlpdQLcqFHxf5oqfRFVpySvjR_Ch7_NCO87h05ChL7Do65vDIFC2H8zhyKnhqXJ6GdsuLw4c276h-TGEcfAfjmWgeYzy6HT6u5UhvhCceZSp0PD5iZzka9Zh05NOEZmsgxZTx50ifa8hxpRv0E1vHKciFHk0cFY0moRKzabgbDb3gH_2RH8k3lGuEKc_x3_hRPehX5ODRfDX6JCtOIVyOMFyP-4XyHWkaF9fRt0VzD7sOJlUkHX2Q9Ed-9PnR8EpwijfCJJFi9PmhLySPhmOC-sIZiI8m_ML3INJ3pI6UknCNnkHzyNDEpchz400d9IN99PiSo9kyDf0xXTrS_HCC79D64Tx4o1YSIReeCKH84Q0ORT7CNMKPmQma62inD7xoodlEJNOJXEHzo3qCMEn4omWg_UPKqBN69EYz5kPyDrkeCb2OKd2i4RJ6PB3CQ5Wo5shTMUH7Hf6IHsd5NNcQnjFGo8oP__DJQz8OJk9s5B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ingerprint(encoded, strlen(encoded), &fp, &length, &algorithm, 1); // string iterator not incrementable       
@CyberSinh
Copy link
Contributor Author

You will below an extract of the Visual Studio xstring header file.
I can define _ITERATOR_DEBUG_LEVEL=0 to workaround the issue in DEBUG mode and the program seems to run fine with that.
But perhaps the chromaprint source code could be changed to be more robust.

	_Myiter& operator++()
		{	// preincrement
 #if _ITERATOR_DEBUG_LEVEL == 2
		const auto _Mycont = static_cast<const _Mystr *>(this->_Getcont());
		if (_Mycont == 0
			|| _Ptr == nullptr_t{}
			|| _Mycont->_Myptr() + _Mycont->_Mysize <= _Unfancy(_Ptr))
			{	// report error
			_DEBUG_ERROR("string iterator not incrementable");
			_SCL_SECURE_OUT_OF_RANGE;
			}

 #elif _ITERATOR_DEBUG_LEVEL == 1
		_SCL_SECURE_VALIDATE(_Ptr != nullptr_t{});
		const auto _Mycont = static_cast<const _Mystr *>(this->_Getcont());
		_SCL_SECURE_VALIDATE(_Mycont != 0);
		_SCL_SECURE_VALIDATE_RANGE(_Unfancy(_Ptr) < _Mycont->_Myptr() + _Mycont->_Mysize);
 #endif /* _ITERATOR_DEBUG_LEVEL */

		++_Ptr;
		return (*this);
		}

@lalinsky
Copy link
Member

I don't have access to a computer with Visual Studio. Can you help me pinpoint the code in Chromaprint that causes this? I don't see anything obviously wrong and Valgrind reports no illegal memory access.

@CyberSinh
Copy link
Contributor Author

CyberSinh commented Dec 18, 2016

Hi Lukas,

You will find below a GIF screencast showing the stack trace:
issue_chromaprint

Thanks.

@lalinsky
Copy link
Member

That is very strange. The code is only iterating up to dest.end(), which should be fine. I guess I'll have to install Visual Studio somewhere to check what exactly is it complaining about.

@lalinsky
Copy link
Member

Hm, actually no, there is something wrong. Thank for catching this. I'll have a fix soon.

@lalinsky
Copy link
Member

It's a shame the C++ library included with GCC doesn't have this kind of iterator checks. Valgrind did not catch this, because std::string allocates one extra byte for the string.

@CyberSinh
Copy link
Contributor Author

Yeah. Visual Studio is a very good IDE for development. And Visual Studio Community is free. You should try.
Thanks for the fix. It works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants