cutting-room-floor / mapbox-gl-cocoa

OBSOLETE
74 stars 12 forks source link

CachingHTTPFileSource access exception #75

Closed donpark closed 9 years ago

donpark commented 9 years ago

In MGLMapView.m, FileSource used to instantiate mbgl::Map is allocated on stack:

 mbglView = new MBGLView(self);
- mbglMap = new mbgl::Map(*mbglView);
+ mbgl::CachingHTTPFileSource fileSource(mbgl::platform::defaultCacheDatabase());
mbglMap = new mbgl::Map(*mbglView, fileSource);

This results in bad access exception later because by the time fileSource is used, it's no longer available.

jfirebaugh commented 9 years ago

The bug here is the access exception/use-after-free, not the fact that it's stack allocated. Can you provide details (stack trace and how to reproduce)?

donpark commented 9 years ago

Exception happens when Map->start is called so it should happen just by viewing a map. Bad access exception is thrown in prepare method called via start -> run.

screenshot_183

If I allocate FileSource in heap, exception is not thrown.

jfirebaugh commented 9 years ago

Oh I see, Map is not stack allocated here. I was assuming it was. You're totally right, everything needs to be heap allocated.