about using frameListMap

Roel roel_v at stack.be
Sat May 6 12:18:31 CEST 2006


Hi,

I have a problem that looks like it's the same as the one Dave Wiard 
wrote to this list about on 7th of April.
I narrowed it down to this program:

#include <tag.h>
#include <mpegfile.h>
#include <id3v2tag.h>

int main(int argc, char* argv[])
{
	TagLib::MPEG::File file("test.mp3");

	TagLib::ID3v2::Tag* id3v2 = file.ID3v2Tag();

	TagLib::ID3v2::FrameList l = id3v2->frameListMap()["APIC"];

	return 0;
}

When this program exits, it tries to deallocate 'file' when unwinding 
the stack. I get a crash as shown in the following stack trace (the 
first couple of lines basically mean that the pointer that was passed to 
the delete operator is not a valid pointer, usually memory that has been 
freed already):

>  	ntdll.dll!7c901230() 	
>  	ntdll.dll!7c96c943() 	
>  	ntdll.dll!7c96cd80() 	
>  	ntdll.dll!7c960af8() 	
>  	kernel32.dll!7c85e7af() 	
>  	TagLibd.dll!_CrtIsValidHeapPointer(const void * pUserData=0x00343e30)  Line 1807	C
>  	TagLibd.dll!_free_dbg(void * pUserData=0x00343e30, int nBlockUse=1)  Line 1132 + 0x9	C
>  	TagLibd.dll!operator delete(void * pUserData=0x00343e30)  Line 54 + 0x10	C++
>  	TagLibd.dll!std::allocator<std::_List_nod<TagLib::ID3v2::Frame *,std::allocator<TagLib::ID3v2::Frame *> >::_Node>::deallocate(std::_List_nod<TagLib::ID3v2::Frame *,std::allocator<TagLib::ID3v2::Frame *> >::_Node * _Ptr=0x00343e30, unsigned int __formal=1)  Line 132 + 0x9	C++
>  	TagLibd.dll!std::list<TagLib::ID3v2::Frame *,std::allocator<TagLib::ID3v2::Frame *> >::_Tidy()  Line 934	C++
>  	TagLibd.dll!std::list<TagLib::ID3v2::Frame *,std::allocator<TagLib::ID3v2::Frame *> >::~list<TagLib::ID3v2::Frame *,std::allocator<TagLib::ID3v2::Frame *> >()  Line 366	C++
>>	TagLibd.dll!TagLib::List<TagLib::ID3v2::Frame *>::ListPrivate<TagLib::ID3v2::Frame *>::~ListPrivate<TagLib::ID3v2::Frame *>()  Line 71 + 0x12	C++
>  	TagLibd.dll!TagLib::List<TagLib::ID3v2::Frame *>::ListPrivate<TagLib::ID3v2::Frame *>::`scalar deleting destructor'()  + 0x2b	C++
>  	TagLibd.dll!TagLib::List<TagLib::ID3v2::Frame *>::~List<TagLib::ID3v2::Frame *>()  Line 103 + 0x2e	C++
>  	TagLibd.dll!std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> >::~pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> >()  + 0x4a	C++
>  	TagLibd.dll!std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node::~_Node()  + 0x2e	C++
>  	TagLibd.dll!std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node::`scalar deleting destructor'()  + 0x2b	C++
>  	TagLibd.dll!std::_Destroy<std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node>(std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node * _Ptr=0x00343e78)  Line 50	C++
>  	TagLibd.dll!std::allocator<std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node>::destroy(std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node * _Ptr=0x00343e78)  Line 152 + 0x9	C++
>  	TagLibd.dll!std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Erase(std::_Tree_nod<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Node * _Rootnode=0x00343e78)  Line 896	C++
>  	TagLibd.dll!std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::clear()  Line 782	C++
>  	TagLibd.dll!std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::erase(std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::iterator _First={...}, std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::iterator _Last={...})  Line 754	C++
>  	TagLibd.dll!std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::_Tidy()  Line 1144	C++
>  	TagLibd.dll!std::_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >::~_Tree<std::_Tmap_traits<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > >,0> >()  Line 393	C++
>  	TagLibd.dll!std::map<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > > >::~map<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *>,std::less<TagLib::ByteVector>,std::allocator<std::pair<TagLib::ByteVector const ,TagLib::List<TagLib::ID3v2::Frame *> > > >()  + 0x2b	C++
>  	TagLibd.dll!TagLib::Map<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >::MapPrivate<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >::~MapPrivate<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >()  + 0x2e	C++
>  	TagLibd.dll!TagLib::Map<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >::MapPrivate<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >::`scalar deleting destructor'()  + 0x2b	C++
>  	TagLibd.dll!TagLib::Map<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >::~Map<TagLib::ByteVector,TagLib::List<TagLib::ID3v2::Frame *> >()  Line 54 + 0x2e	C++
>  	TagLibd.dll!TagLib::ID3v2::Tag::TagPrivate::~TagPrivate()  Line 49 + 0x1e	C++
>  	TagLibd.dll!TagLib::ID3v2::Tag::TagPrivate::`scalar deleting destructor'()  + 0x2b	C++
>  	TagLibd.dll!TagLib::ID3v2::Tag::~Tag()  Line 89 + 0x2e	C++
>  	TagLibd.dll!TagLib::ID3v2::Tag::`vector deleting destructor'()  + 0x69	C++
>  	TagLibd.dll!TagLib::MPEG::File::FilePrivate::~FilePrivate()  Line 189 + 0x35	C++
>  	TagLibd.dll!TagLib::MPEG::File::FilePrivate::`scalar deleting destructor'()  + 0x2b	C++
>  	TagLibd.dll!TagLib::MPEG::File::~File()  Line 246 + 0x2e	C++
>  	taglibtest.exe!main(int argc=1, char * * argv=0x003418f0)  Line 18 + 0x28	C++
>  	taglibtest.exe!mainCRTStartup()  Line 259 + 0x19	C
>  	kernel32.dll!7c816d4f() 	
>  	ntdll.dll!7c915b4f() 	
>  	kernel32.dll!7c8399f3() 	



As you can see it's on Windows. The test file used didn't contain any 
"APIC" frames, which seems to be important - it's no problem when I use 
a file that has 1 or more of those frames.
The problems seem to start in

   ~ListPrivate() {
     clear();
   }

in tlist.tcc.

Can anyone confirm this problem exists on non-Windows platforms? Am I 
doing something wrong or is there some problem somewhere with the list 
handling in TagLib? Thanks.


cheers,

roel



More information about the taglib-devel mailing list