Giving more details as not sure what the deal here is. The idea of this 
project is to share my C++ backend across Web, iOS and Android. I've done 
the latter two before so I figured I should start with web. This is 
effectively a library so I'm building it with the following arguments into 
emcc: -O0 -g4 -s MODULARIZE=1 -s NO_EXIT_RUNTIME=1 -s EXCEPTION_DEBUG=1

The structure of this code is
app: App
 - createdBusiness: Business
   - products: std::vector<Product>
 - user: User
   - checkins: std::vector<Checkins>

The scenario is:

   1. The user creates a business - app.createBusinessAsync();
   2. Checks into the business - 
   app.user.createCheckinAsync(app.createdBusiness)
   3. Reads the product for that business - 
   app.createdBusiness.readProductsAsync()
   4. Creates a new product for that business - 
   app.createdBusiness.createProductAsync(name)

At step 3 I am currently getting a *bad_weak_ptr* exception on the object 
business when calling *this->shared_from_this()*.
*If I remove step 2, I no longer get a bad_weak_ptr at step 3.*

Here's where things get weird... I added two methods to verify it wasn't 
createCheckinAsync causing some weird pointer issue

   - app.businessTestAsync()
   - user.businessTestAsync()

Both of which look like this (one for App one for User though)
void App::businessTestAsync(std::shared_ptr<Business> business)
{
    printf("App::businessTestAsync - Entered\n");
    business->shared_from_this();
    printf(".use_count(): %ld \n", business->shared_from_this().use_count
());
    printf("App::businessTestAsync - shared_from_this\n");
    printf("App::businessTestAsync - Exited\n");
}

Replacing step 2 with calling either of these methods also causes a 
bad_weak_ptr when attempting to run any method on the Business object.

I have a printf in the destructor of Business so I'm fairly sure it's not 
being destroyed...

Can I provide any other information to help figure out the next steps to 
debugging? I'm also willing to zip up the contents of my project and share 
it if needed.

-- 
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.

Reply via email to