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

Exception during using libosrm #5240

Open
safe-bug opened this issue Oct 19, 2018 · 8 comments
Open

Exception during using libosrm #5240

safe-bug opened this issue Oct 19, 2018 · 8 comments

Comments

@safe-bug
Copy link

safe-bug commented Oct 19, 2018

Hello
I'm using the latest libosrm (v5.19.0) that is called using JNI in java. But I get this exception while the server is running and it gets stopped after. I'm using the MLD algorithm and shared memory for this service.
What is the problem and how can I fix this?

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f5f8290c359, pid=31933, tid=0x00007f5e65684700
#
# Problematic frame:
# C  [libosrmBinding.so+0xd9359]  unsigned char const* std::__find_if<unsigned char const*, __gnu_cxx::__ops::_Iter_equals_val<unsigned char const> >(unsigned char const*, unsigned char const*, __gnu_cxx::__ops::_Iter_equals_val<unsigned char const>, std::random_access_iterator_tag)+0x19
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)
@danpat
Copy link
Member

danpat commented Oct 19, 2018

@behizz Couple of things:

  • OSRM 5.19.0 has not yet been released - are you using code from master ? While we try to keep it stable, it's not necessarily fully tested.
  • JNI bindings - did you write these? It sounds like you need to build them with debug symbols enabled so we can figure out a line number where the segfault is occurring. Without more detailed information, it's hard to say where the bug is - in libosrm, or inside your JNI binding code.

@danpat
Copy link
Member

danpat commented Oct 19, 2018

One easy way to test whether the bug is in OSRM, or your JNI code would be to use osrm-routed to query a route from your datafiles using HTTP. That'll narrow down whether the problem is inside OSRM itself, or in your JNI binding layer.

@safe-bug
Copy link
Author

@danpat Thanks for the reply
I saw the 5.19.0 in the release page without any RC tag and I thought it is a release version, anyway thanks for the notice. I installed the 5.18.0 version and the issue still exists.
This time I built it in debug mode and the exception is this. The routing requests are normal requests, it just happens after a while the server is running and of course the shared memory dataset is getting updated.

[assert][139637710132992] osrm-backend-5.18.0/include/util/query_heap.hpp:280
in: Weight osrm::util::QueryHeap<NodeID, Key, Weight, Data, IndexStorage>::MinKey() const [with NodeID = unsigned int; Key = unsigned int; Weight = int; Data = osrm::engine::MultiLayerDijkstraHeapData; IndexStorage = osrm::util::TwoLevelStorage<unsigned int, int>]: !heap.empty()
terminate called without an active exception
Aborted (core dumped)

@safe-bug
Copy link
Author

safe-bug commented Oct 24, 2018

@danpat
The actual stack trace of my main issue is this (The last one I copied was about another issue):
It seems that the exception occurs inside OSRM not in JNI codes. Can you help me to prevent or fix this?

Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libosrmBinding.so+0x3900cc]  bool __gnu_cxx::__ops::_Iter_equals_val<unsigned char const>::operator()<unsigned char const*>(unsigned char const*)+0xa
C  [libosrmBinding.so+0x390109]  unsigned char const* std::__find_if<unsigned char const*, __gnu_cxx::__ops::_Iter_equals_val<unsigned char const> >(unsigned char const*, unsigned char const*, __gnu_cxx::__ops::_Iter_equals_val<unsigned char const>, std::random_access_iterator_tag)+0x36
C  [libosrmBinding.so+0x3901f6]  unsigned char const* std::__find_if<unsigned char const*, __gnu_cxx::__ops::_Iter_equals_val<unsigned char const> >(unsigned char const*, unsigned char const*, __gnu_cxx::__ops::_Iter_equals_val<unsigned char const>)+0xf
C  [libosrmBinding.so+0x39021f]  unsigned char const* std::find<unsigned char const*, unsigned char>(unsigned char const*, unsigned char const*, unsigned char const&)+0x23
C  [libosrmBinding.so+0x3b297a]  osrm::engine::DataFacadeFactory<osrm::engine::datafacade::ContiguousInternalMemoryDataFacade, osrm::engine::routing_algorithms::mld::Algorithm>::Get(osrm::engine::api::BaseParameters const&, std::integral_constant<bool, true>) const+0x10e
C  [libosrmBinding.so+0x3b2a10]  std::shared_ptr<osrm::engine::datafacade::ContiguousInternalMemoryDataFacade<osrm::engine::routing_algorithms::mld::Algorithm> const> osrm::engine::DataFacadeFactory<osrm::engine::datafacade::ContiguousInternalMemoryDataFacade, osrm::engine::routing_algorithms::mld::Algorithm>::Get<osrm::engine::api::BaseParameters>(osrm::engine::api::BaseParameters const&) const+0x22
C  [libosrmBinding.so+0x3b2a55]  osrm::engine::detail::DataWatchdogImpl<osrm::engine::routing_algorithms::mld::Algorithm, osrm::engine::datafacade::ContiguousInternalMemoryDataFacade<osrm::engine::routing_algorithms::mld::Algorithm> >::Get(osrm::engine::api::BaseParameters const&) const+0x27
C  [libosrmBinding.so+0x3b2a98]  osrm::engine::detail::WatchingProvider<osrm::engine::routing_algorithms::mld::Algorithm, osrm::engine::datafacade::ContiguousInternalMemoryDataFacade>::Get(osrm::engine::api::BaseParameters const&) const+0x24
C  [libosrmBinding.so+0x3b191f]  _ZNK4osrm6engine6EngineINS0_18routing_algorithms3mld9AlgorithmEE13GetAlgorithmsINS0_3api15RouteParametersEEEDaRKT_+0x43
C  [libosrmBinding.so+0x3b1993]  osrm::engine::Engine<osrm::engine::routing_algorithms::mld::Algorithm>::Route(osrm::engine::api::RouteParameters const&, osrm::util::json::Object&) const+0x39
C  [libosrmBinding.so+0x38c28b]  osrm::OSRM::Route(osrm::engine::api::RouteParameters const&, osrm::util::json::Object&) const+0x21

@danpat
Copy link
Member

danpat commented Oct 24, 2018

Looks like it's crashing here:

https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/datafacade_factory.hpp#L128

or here:

https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/datafacade_factory.hpp#L139

it's a bit hard to tell without line numbers in your stack trace.

My suspicion is that you haven't configured the OSRM object inside your JNI bindings correctly. Can you describe exactly how you initialize the OSRM object (like, show us your code, or link to it?)

@safe-bug
Copy link
Author

safe-bug commented Oct 24, 2018

@danpat
This is the code where I configure the OSRM object and make a route request. I generate jni files using swig.

namespace company {
    Engine::Engine(const std::string &datasetName, int maxAlternatives) {
        osrm::EngineConfig engineConfig;
        engineConfig.use_shared_memory = true;
        engineConfig.algorithm = osrm::EngineConfig::Algorithm::MLD;
        engineConfig.dataset_name = datasetName;
        engineConfig.max_alternatives = maxAlternatives;
        osrm = std::make_shared<osrm::OSRM>(engineConfig);
    }

    std::string Engine::route(std::vector<RoutePoint> points,
                              std::vector<Bearing> bearings,
                              unsigned int numberOfAlternatives, bool annotations) {
        using namespace osrm;
        RouteParameters param;
        for (auto pt:points) {
            param.coordinates.push_back({util::FloatLongitude{pt.longitude}, util::FloatLatitude{pt.latitude}});
        }
        param.number_of_alternatives = numberOfAlternatives;
        param.geometries = RouteParameters::GeometriesType::Polyline;
        param.steps = true;

        std::vector<boost::optional<engine::Bearing>> osrmBearings;
        for (auto b:bearings) {
            engine::Bearing x = {b.bearing, b.range};
            osrmBearings.emplace_back(x);
        }
        param.bearings = osrmBearings;
        param.annotations = annotations;
        param.overview = RouteParameters::OverviewType::Full;
        json::Object result;
        osrm->Route(param, result);
        std::stringstream ss;
        util::json::Renderer renderer(ss);
        renderer(result);
        return ss.str();
    }
}

@giser-yugang
Copy link

@safe-bug Hello, did you succeed? I also want to use libosrm.so that is called using JNI in java. Can you give me some guidance?

@safe-bug
Copy link
Author

@giser-yugang Unfortunately no, I still have this issue with the engine. @oxidase Do you have any idea how to fix it?

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

No branches or pull requests

3 participants