Given the attached DAE file. Blender would crash in
bool ExtraHandler::textData(const char* text, size_t textLength)
with currentExtraTags being a NULL pointer.
My patch checks the custom element node for understanding and returns false if it's not one that the current implementation understands.
Description
Event Timeline
First of all, thanks for submitting your patch.
Two issues:
1) The attached .dae crashes with official 2.57b build, but not with current trunk
2) The proposed patch completely disables importing back blender profile in current trunk. This can be tested by doing an export with a Blender Lamp, then reimport. Current code works as expected.
The elementBegin() function is called only when inside a profile, not outside one. The parseElement handles already unknown profiles (XSI, CustomEngine).
Please provide a backtrace in case you still get this, and report what OpenCOLLADA version you are using, and what Blender code revision. On Windows we have r839 for OpenCOLLADA (with small unrelated patch applied), and r37659 of Blender trunk is what I just tested with.
As it currently stands, I'd reject the patch, but I leave the report open in case you want to provide an updated patch.
Note, when you do provide a new patch, please make sure it is in the format that 'svn diff' would create. My patch tools don't like the Git format.
Working from head (code & libs) in win64 using cmake the callstack I get is
----
> blender.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >,0> >::_Root() Line 1325 + 0x5 bytes C++
blender.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >,0> >::_Lbound(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval="technique") Line 1264 + 0xa bytes C++
blender.exe!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >,0> >::lower_bound(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval="technique") Line 1004 + 0xf bytes C++
blender.exe!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,std::basic_string<char,std::char_traits<char>,std::allocator<char> > > > >::operator[](const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & _Keyval="technique") Line 169 + 0x1a bytes C++
blender.exe!ExtraTags::addTag(std::basic_string<char,std::char_traits<char>,std::allocator<char> > * tag="technique", std::basic_string<char,std::char_traits<char>,std::allocator<char> > * data="
") Line 54 + 0x13 bytes C++
blender.exe!ExtraHandler::textData(const char * text=0x000000000fa6c42c, unsigned __int64 textLength=25) Line 61 C++
blender.exe!COLLADASaxFWL::ExtraDataElementHandler::textData() + 0xc8 bytes
blender.exe!GeneratedSaxParser::ParserTemplate<COLLADASaxFWL14::ColladaParserAutoGen14Private,COLLADASaxFWL14::ColladaParserAutoGen14>::textData() + 0xb1 bytes
blender.exe!GeneratedSaxParser::LibxmlSaxParser::characters() + 0x60 bytes
blender.exe!xmlParseCharData() + 0x2ad bytes
blender.exe!xmlParseContent() + 0x2a0 bytes
blender.exe!xmlParseElement() + 0x708 bytes
blender.exe!xmlParseContent() + 0x279 bytes
blender.exe!xmlParseElement() + 0x708 bytes
blender.exe!xmlParseContent() + 0x279 bytes
blender.exe!xmlParseElement() + 0x708 bytes
blender.exe!xmlParseContent() + 0x279 bytes
blender.exe!xmlParseElement() + 0x708 bytes
blender.exe!xmlParseContent() + 0x279 bytes
blender.exe!xmlParseElement() + 0x708 bytes
blender.exe!xmlParseContent() + 0x279 bytes
blender.exe!xmlParseElement() + 0x708 bytes
blender.exe!xmlParseDocument() + 0x624 bytes
blender.exe!GeneratedSaxParser::LibxmlSaxParser::parseFile() + 0x1d2 bytes
blender.exe!COLLADASaxFWL::VersionParser::createAndLaunchParser() + 0xbf bytes
blender.exe!COLLADASaxFWL::FileLoader::load() + 0xaa bytes
blender.exe!COLLADASaxFWL::Loader::loadDocument() + 0x26f bytes
blender.exe!COLLADAFW::Root::loadDocument() + 0x6a bytes
blender.exe!DocumentImporter::import() Line 124 + 0x19 bytes C++
blender.exe!collada_import(bContext * C=0x0000000001e67a78, const char * filepath=0x000000000031f560) Line 51 C++
blender.exe!wm_collada_import_exec(bContext * C=0x0000000001e67a78, wmOperator * op=0x000000000f9ef0a8) Line 2013 C
blender.exe!wm_handler_fileselect_call(bContext * C=0x0000000001e67a78, ListBase * handlers=0x0000000002407878, wmEventHandler * handler=0x000000000f9fc508, wmEvent * event=0x000000000f9fdd58) Line 1355 + 0x27 bytes C
blender.exe!wm_handlers_do(bContext * C=0x0000000001e67a78, wmEvent * event=0x000000000f9fdd58, ListBase * handlers=0x0000000002407878) Line 1496 + 0x22 bytes C
blender.exe!wm_event_do_handlers(bContext * C=0x0000000001e67a78) Line 1787 + 0x1e bytes C
blender.exe!WM_main(bContext * C=0x0000000001e67a78) Line 349 C
blender.exe!main(int argc=1, const unsigned char * * argv=0x0000000001d03c50) Line 1305 C
blender.exe!__tmainCRTStartup() Line 266 + 0x19 bytes C
blender.exe!mainCRTStartup() Line 182 C
kernel32.dll!BaseThreadInitThunk() + 0xd bytes
ntdll.dll!RtlUserThreadStart() + 0x21 bytes
----
The problem seems to be that the textData function is called before parseElement, hence the currentExtraTags member is NULL.
I see why the patch is failing. I'll rework it.
Thanks
I see that the problem is a malformed COLLADA file, I'm not sure how to report the error at
this time to the loader. I don't think that the crash is a safe way to go and so there should be
a NULL check in the textData function but you don't need a patch for that.
You can close this.