Address 5 is not a valid memory address, so there must be a corrupt pointer here. If the error happens around the for, perhaps it occurs in the code preparing for the printf before it or in the loop? The latter seems more suspicious, as it does a dereference. If nEntry for example is too high a value for the array m_regions, then it will load .type on invalid data, and might happen to find "5" there.
I would print out before the failing printf, something like the value of m_regions, m_nRegions, the address of m_regions[nEntry], the address of m_regions[nEntry].type, etc. On Wed, Oct 14, 2015 at 2:17 PM, Mark Meier <[email protected]> wrote: > I have a C++ class CAppStruct with method RegionsToObjList() that returns > a pointer to a C++ class CElementList. > I listed a code snippet with line number. > > 516: CElementList* CAppStruct::RegionsToObjList() const > 517: { > 518: long nEntry; > 519: > 520:printf("%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); > 521: if (m_regions == NULL || m_nRegions <= 0) > 522: { > 523:printf("%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); > 524: return NULL; > 525: } > 526: > 527:printf("%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); > 528: CElementList *pList = new CElementList(); > 529: > 530:printf("%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); > 531: CCgmBaseObj* pObj = NULL; > 532:printf("%s:%s:%d &m_nRegions=%ld\n", __FILE__, __FUNCTION__, > __LINE__, &m_nRegions); > 533: for (nEntry = 0; nEntry < m_nRegions; nEntry++) > 534: { > 535:printf("%s:%s:%d m_nRegions=%d type=%d\n", __FILE__, __FUNCTION__, > __LINE__, m_nRegions, m_regions[nEntry].type); > . > . > . > 660: } > 661: > 662:printf("%s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__); > > This is the end of the output I get when I run. > > AppStruct.cpp:RegionsToObjList:520 > module.js:1983 > AppStruct.cpp:RegionsToObjList:527 > module.js:1983 > AppStruct.cpp:RegionsToObjList:530 > module.js:1983 > AppStruct.cpp:RegionsToObjList:532 &m_nRegions=100 > module.js:1983 > alignment error loading from address 5, which was expected to be > aligned to a multiple of 4 > > It appears to be aborting on the "for" statement. The variable > "m_nRegions" was already accessed on line 521 and didn't fail. > > Any thoughts or suggestions? > Thanks > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
