TagLib 1.9.1 crash using C++11

Festus Hagen festushagenlists at yahoo.com
Mon Jun 22 22:09:37 UTC 2015


Somehow this got off the list, this re-introduces it back onto the list.


Ibrahim Sha'ath,The code works using GCC c++11 on Windows, FreeBSD and OS X. (That is GNU's not Apples ...).
However I don't believe the following provides the result expected.
  if(mp4File != NULL){
I suspect the following would.

  if(mp4File->isValid()){

If TagLib::FileRef and TagLib::File are not actually used other then to create mp4File, The following

  TagLib::FileRef *fr = new TagLib::FileRef("/Users/ibrahimshaath/Downloads/test.m4a");
  TagLib::File *f = fr->file();
  TagLib::MP4::File *mp4File = dynamic_cast<TagLib::MP4::File*>(f);
can be reduced to

  TagLib::MP4::File *mp4File = new TagLib::MP4::File("/Users/ibrahimshaath/Downloads/test.m4a");

At this point in time I am still unable to get Clang to build on this OS X10.5.8 box, I'm not an Apple person, It was free, it's a dual 2.3Mhz PPC G5, I wanted a Big Endian test box, it fit the bill, I think!

Anything more I can do to help, feel free to ask!

-Enjoy
: )_~

________________________________
From: Ibrahim Sha'ath <ibrahimshaath at gmail.com>
To: Festus Hagen <festushagenlists at yahoo.com> 
Sent: Sunday, June 21, 2015 4:43 AM
Subject: Re: TagLib 1.9.1 crash using C++11



Hey Festus,

I rewrote this into a sample app so you can see everything that's going on. This crashes the same way:

int main() {
  TagLib::FileRef *fr = newTagLib::FileRef("/Users/ibrahimshaath/Downloads/test.m4a");
  TagLib::File *f = fr->file();
  TagLib::MP4::File *mp4File = dynamic_cast<TagLib::MP4::File*>(f);
  TagLib::String key = TagLib::String("\251grp");

  if (mp4File != NULL) {
    cout << "MP4filefound" << endl;
    if(mp4File->tag()->itemListMap().contains(key)) {
      TagLib::MP4::Itemi = mp4File->tag()->itemListMap()[key];
      TagLib::Stringstr = i.toStringList().front();
      cout << "Grouping:" << str.toCString(true) << endl;
    }

    TagLib::StringList sl(TagLib::String("DATA"));
    mp4File->tag()->itemListMap().insert(key, TagLib::MP4::Item(sl));
    cout << "Groupingdatainserted" << endl;
    mp4File->save();
    cout << "Filesaved" << endl;
  }
  return0;
}
It works if I compile it without C++11. With C++11, it can't read the itemListMap and crashes on insert. I haven't had the time to delve into the TagLib codebase and see what I might have done wrong, so I really appreciate your help and familiarity with the lib.

Best
Ibrahim




On 20 June 2015 at 17:11, Festus Hagen <festushagenlists at yahoo.com> wrote:

Whoops ... I should of been more clear, I didn't expect it to resolve the crash, just eliminating the obvious.
>Like I said previously, The example code you provided works as is, even though it's slightly improper.
>
>The first parameter (the key) is a TagLib::String not a c_string, it behooves you to use proper data types.
>
>It appears you have an Mp4FileMetadata class with a setGrouping(QString const&) function.
>
>I assume that is where the snippet of code you posted came from?
>May we see the entire function?
>
>
>Also, You should strip down your code to be as simple as possible and still have the issue, I suspect you have an overrun or the like someplace and this just happens to be where it's getting stepped on ...
>
>If you want, I'll send/post my test kissapp (and its CMakeLists.txt) so you can try it on your system, it is short, simple and to the point, though not pretty.
>
>The CMakeLists is hard coded to find TagLib and would need modification to fit your system.
>
>
>-Enjoy
>: )_~
>
>________________________________
>From: Ibrahim Sha'ath <ibrahimshaath at gmail.com>
>To: Festus Hagen <festushagenlists at yahoo.com>; taglib-devel at kde.org
>Sent: Friday, June 19, 2015 1:45 PM
>
>Subject: Re: TagLib 1.9.1 crash using C++11
>
>
>
>Unfortunately, that did not prevent the crash, though it did shorten the stack:
>
>0 ... std::__1::map<TagLib::String, TagLib::MP4::Item, std::__1::less<TagLib::String>, std::__1::allocator<std::__1::pair<TagLib::String const, TagLib::MP4::Item> > >::operator[](TagLib::String const&) + 211
>1 ... Mp4FileMetadata::setGrouping(QString const&) + 195
>
>As it turned out I had already implemented this change in almost every similar method in my app, but not that one! So thanks for pointing it out. I've also tried using a TagLib::String as the map key rather than just the C-string, but to no avail. I didn't notice the MP4::Tag::item property implementation in master, but I'll take another look.
>
>By any chance does the shorter stack clarify anything?
>
>Thanks again.
>
>
>
>
>On 19 June 2015 at 14:11, Ibrahim Sha'ath <ibrahimshaath at gmail.com> wrote:
>
>Festus, thank you very much. That looks spot on. Let me try it out when I get home.
>>
>>
>>On 19 June 2015 at 01:55, Festus Hagen <festushagenlists at yahoo.com> wrote:
>>
>>Hi,
>>>
>>>The following particulate from your stack trace shows that the second argument to insert() is a TagLib::MP4::Item not a TagLib::StringList ...
>>>> insert(TagLib::String const&, TagLib::MP4::Item const&)
>>>
>>>However, I did wrap your sample code with the rest of the necessities and it tests fine using GCC c++11 on Windows, FreeBSD and OS X.
>>>
>>>I shall try CLang when it's done building ...
>>>
>>>Might I suggest a slight code change: mp4File->tag()->itemListMap().insert("\251grp", TagLib::MP4::Item(sl));
>>>
>>>TagLib master has new accessors MP4::Tag::item(const String &key) and MP4::Tag::setItem(const String &key, const Item &value) for this in the next release.
>>>
>>>-Enjoy
>>>: )_~
>>>________________________________
>>>From: Ibrahim Sha'ath <ibrahimshaath at gmail.com>
>>>To: taglib-devel at kde.org
>>>Sent: Thursday, June 11, 2015 2:11 PM
>>>Subject: Re: TagLib 1.9.1 crash using C++11
>>>
>>>
>>>
>>>
>>>Hmmm. taglib2 didn't work either. A simpler stack trace, but looks like the same crash essentially:
>>>
>>>0 ... 0x0000000108214283 std::__1::map<TagLib::String, TagLib::MP4::Item, std::__1::less<TagLib::String>, std::__1::allocator<std::__1::pair<TagLib::String const, TagLib::MP4::Item> > >::operator[](TagLib::String const&) + 211
>>>1 ... 0x00000001082132f1 TagLib::Map<TagLib::String, TagLib::MP4::Item>::insert(TagLib::String const&, TagLib::MP4::Item const&) + 97
>>>
>>>Is anyone successfully using the itemListMap with C++11? I can't read from it either, though that doesn't crash.
>>>
>>>
>>>
>>>
>>>
>>>On 11 June 2015 at 18:33, Ibrahim Sha'ath <ibrahimshaath at gmail.com> wrote:
>>>
>>>Sadly, current master didn't improve matters, so I imagine neither will that specific tag.
>>>>I'll try out the v2 branch.
>>>>
>>>>
>>>>On 5 June 2015 at 09:36, Ibrahim Sha'ath <ibrahimshaath at gmail.com> wrote:
>>>>
>>>>Excellent Rob, cheers; I'll definitely check that out.
>>>>>
>>>>>
>>>>>Your email ended up in spam for some reason.
>>>>>
>>>>>
>>>>>On 5 June 2015 at 09:03, Rob Arnold <rob at loci.net> wrote:
>>>>>
>>>>>Same, but with master (specifically v1.9.1-197-g62ab41f), so perhaps a little closer to 1.9.1 than the taglib2 branch
>>>>>>On OS X 10.10 with Clang, C++11 and 14 options turned on.
>>>>>>My code uses StringList, File:save() and tag(), but doesn’t directly use itemListMap()
>>>>>>
>>>>>>
>>>>>>On Jun 4, 2015, at 7:02 PM, Stephen F. Booth <me at sbooth.org> wrote:
>>>>>>>
>>>>>>>I've used TagLib and C++11 successfully together, however I used the taglib2 branch and not the 1.9.1 release.  Some of my classes using TagLib are at https://github.com/sbooth/SFBAudioEngine/tree/master/Metadata if you'd like to take a look.
>>>>>>>
>>>>>>>
>>>>>>>Stephen
>>>>>>>
>>>>>>>
>>>>>>>On Wed, Jun 3, 2015 at 8:45 AM, Ibrahim Sha'ath <ibrahimshaath at gmail.com> wrote:
>>>>>>>
>>>>>>>If no-one has any idea about this issue specifically, has anyone successfully used C++11 for a TagLib 1.9.1 project?
>>>>>>
>>>>>>_______________________________________________
>>>>>>taglib-devel mailing list
>>>>>>taglib-devel at kde.org
>>>>>>https://mail.kde.org/mailman/listinfo/taglib-devel
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>>_______________________________________________
>>>taglib-devel mailing list
>>>taglib-devel at kde.org
>>>https://mail.kde.org/mailman/listinfo/taglib-devel
>>>_______________________________________________
>>>taglib-devel mailing list
>>>taglib-devel at kde.org
>>>https://mail.kde.org/mailman/listinfo/taglib-devel
>>>
>>
>


More information about the taglib-devel mailing list