Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Crash on Transform::setScale() #3607

Closed

Description

@tmpsantos

Also observed when calling Map::setZoom() using padding repeatedly which internally calls Transform::setScale().

https://travis-ci.org/mapbox/mapbox-gl-native/jobs/103073819#L1353

Program received signal SIGSEGV, Segmentation fault.
std::_Function_handler<mbgl::Update (std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >), mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::function<mbgl::Update (double)>, std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&)::{lambda(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >)#1}>::_M_invoke(std::_Any_data const&, std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >) () at /usr/include/c++/4.9/functional:2275
2275        if (_M_manager)
Thread 1 (Thread 0x2aaaaaaf2580 (LWP 12797)):
#0  std::_Function_handler<mbgl::Update (std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >), mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::function<mbgl::Update (double)>, std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&)::{lambda(std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >)#1}>::_M_invoke(std::_Any_data const&, std::chrono::time_point<std::chrono::_V2::steady_clock, std::chrono::duration<long, std::ratio<1l, 1000000000l> > >) () at /usr/include/c++/4.9/functional:2275
#1  0x00000000005df9d4 in mbgl::Transform::startTransition(mbgl::CameraOptions const&, mbgl::AnimationOptions const&, std::function<mbgl::Update (double)>, std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&) () at /usr/include/c++/4.9/functional:2439
#2  0x00000000005e0351 in mbgl::Transform::easeTo(mbgl::CameraOptions const&, mbgl::AnimationOptions const&) () at ../../src/mbgl/map/transform.cpp:145
#3  0x00000000005e0cbe in mbgl::Transform::setScale(double, mbgl::vec2<double> const&, std::chrono::duration<long, std::ratio<1l, 1000000000l> > const&) () at ../../src/mbgl/map/transform.cpp:416
#4  0x00000000004c7d9b in Transform_InvalidScale_Test::TestBody() () at ../../test/miscellaneous/transform.cpp:16
#5  0x00000000006e68a3 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ()

/cc @1ec5

Activity

  1. tmpsantos commented on Jan 19, 2016

    @tmpsantos
    ContributorAuthor

    The backtrace is not very helpful because lambdas. Manually keeping track of function calls I found out that the crash has something to do with recursion.

    The usually looks like:

    void mbgl::Transform::setScale(double, const PrecisionPoint&, const Duration&) {
        void mbgl::Transform::easeTo(const mbgl::CameraOptions&, const mbgl::AnimationOptions&) {
        }
    }
    

    But when it crashes, what I get is:

    void mbgl::Transform::setScale(double, const PrecisionPoint&, const Duration&) {
        void mbgl::Transform::easeTo(const mbgl::CameraOptions&, const mbgl::AnimationOptions&) {
            void mbgl::Transform::setLatLng(const mbgl::LatLng&, const mbgl::EdgeInsets&, const Duration&) {
                void mbgl::Transform::easeTo(const mbgl::CameraOptions&, const mbgl::AnimationOptions&) {
                }
            }
            void mbgl::Transform::setLatLng(const mbgl::LatLng&, const mbgl::EdgeInsets&, const Duration&) {
                void mbgl::Transform::easeTo(const mbgl::CameraOptions&, const mbgl::AnimationOptions&) {
                }
            }
            void mbgl::Transform::setLatLng(const mbgl::LatLng&, const mbgl::EdgeInsets&, const Duration&) {
                void mbgl::Transform::easeTo(const mbgl::CameraOptions&, const mbgl::AnimationOptions&) {
                }
            }
            void mbgl::Transform::setLatLng(const mbgl::LatLng&, const mbgl::EdgeInsets&, const Duration&) {
                void mbgl::Transform::easeTo(const mbgl::CameraOptions&, const mbgl::AnimationOptions&) {
                }
            }
            CRASH!
    

    So easeTo is calling setLatLng which call easeTo again. Possibly invalidating the state set by setScale.

  2. tmpsantos commented on Jan 19, 2016

    @tmpsantos
    ContributorAuthor

    The issue lies on calling view.notifyMapChange(isAnimated ? MapChangeRegionDidChangeAnimated : MapChangeRegionDidChange); that depending on what the client is doing, can cause the recursion.

  3. 1ec5 commented on Jan 19, 2016

    @1ec5
    Contributor

    As a rule, MGLMapView responds to these notifications by calling out to the main thread asynchronously, avoiding any recursion. Maybe we can put in a guard of some sort to fail sooner instead of crashing this way.

  4. tmpsantos commented on Jan 19, 2016

    @tmpsantos
    ContributorAuthor

    As a rule, MGLMapView responds to these notifications by calling out to the main thread asynchronously, avoiding any recursion. Maybe we can put in a guard of some sort to fail sooner instead of crashing this way.

    The problem of responding this async is that if you wanna paint things on top of the map in sync with the transform, you are always going to be one frame behind.

  5. tmpsantos commented on Jan 29, 2016

    @tmpsantos
    ContributorAuthor

    Closing as it was mostly an API misuse from my side.

  6. 1ec5 commented on Jan 29, 2016

    @1ec5
    Contributor

    What explains the failure on Travis, then? Has that crash appeared since?

  7. tmpsantos commented on Jan 29, 2016

    @tmpsantos
    ContributorAuthor

    What explains the failure on Travis, then? Has that crash appeared since?

    I've not seen this one on Travis again.

    I ran the utests literally thousand times trying to reproduce without success. We can re-open if we ever see it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions