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

MemoryPoolAllocator crash #548

Closed
matthewlehew opened this issue Feb 16, 2016 · 4 comments
Closed

MemoryPoolAllocator crash #548

matthewlehew opened this issue Feb 16, 2016 · 4 comments
Labels

Comments

@matthewlehew
Copy link

Hello!

I'm new to C++ and rapidjson, but I'm using it in the prototype of the game I'm putting together. At this point, all I'm trying to do is write a simple key pair to a file to make sure it's set up correctly, but I'm getting a crash each time.

My class definitions for rapidjson:
https://gist.github.com/matthewlehew/755fae28780bb99edbf0

When the main Cocos2dx scene inits, it calls the GameData::startup method. Based on backtrace, it looks like the EXC_BAD_ACCESS is happening during the SetObject method implemented in GameData::createScores().

Debug readout (error is on line 16):
https://gist.github.com/matthewlehew/26dde2ac39d6dd07c738

Based on reading of #412, I changed the GameData::startup method to the one that's currently commented out in the above file. When using that one, the EXC_BAD_ACCESS happens later on, within the GameData::writeScores() block.

Debug readout (error is on line 6):
https://gist.github.com/matthewlehew/28e7a29f40e8caebc64b

Any suggestions on how to proceed at this point? I apologize if I left out any important data, I'm new to rapidjson and to Xcode.

@miloyip
Copy link
Collaborator

miloyip commented Feb 16, 2016

Can you make sure that only one copy of RapidJSON code in the project? If multiple versions of headers are used at the same time, there may be strange crash.
By the way, it may be easier to use debugging functions in XCode to trace step by step to see if something wrong around the locations before the crash.

@matthewlehew
Copy link
Author

Thank you for responding!

I've checked, and the RapidJSON headers are only contained in GameData.cpp and GameData.hpp, and I only have one copy of the RapidJSON code in the project.

I'm not exactly sure what to look for in the backtrace, but it looks like everything in the class files is being called correctly: the main scene's init() calls the GameData::startup() function, which successfully executes GameData::createScores() (as long as I use the code I found in #412).

The next step is GameData::writeScores(), and according to the trace, the fault is happening at the scores.Accept(writer); step.

Here is the readout that shows the fault at the scores.Accept step, fault at 93
Here is the readout from the subsequent step, fault at 11
And here is the final step, which is the same as one of the steps I posted earlier, fault at 6

@miloyip
Copy link
Collaborator

miloyip commented Feb 18, 2016

I asked about the one version issue because cocos2d-x has used a version of RapidJSON internally. Are you using their header files also?

The situations you described looks strange. If you can try to make a minimal test case (ideally without other dependencies such as cocos3d-x), I may help you to find out the problem.

@matthewlehew
Copy link
Author

This wound up being entirely my mistake: I failed to properly initialize the class I had designated to handle RapidJSON. Thank you for your help!

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

No branches or pull requests

2 participants