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

verify that data is valid before generating journeys #142

Open
wants to merge 1 commit into
base: v2c
Choose a base branch
from

Conversation

kaligrafy
Copy link
Collaborator

the two while loops in forward and reverse journey can create memory leak (infinite push into a vector) when invalid data is found (like reverse travel times or incorrectly rounded/floored/ceiled travel time seconds that was imported as float, see #141, needs testing though to close issue

@kaligrafy
Copy link
Collaborator Author

kaligrafy commented May 27, 2022

need your help for testing!

@kaligrafy kaligrafy force-pushed the addExceptionWithInvalidDataInWhileLoops branch from 9de27d5 to 18946c7 Compare May 27, 2022 16:03
@@ -321,6 +321,8 @@ namespace TrRouting
NO_SERVICE_FROM_ORIGIN,
// There is no service to destination with the query parameters
NO_SERVICE_TO_DESTINATION
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need a comma here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@kaligrafy kaligrafy force-pushed the addExceptionWithInvalidDataInWhileLoops branch from 18946c7 to 5b97052 Compare May 27, 2022 16:58
@kaligrafy kaligrafy requested a review from tahini May 27, 2022 16:59
@kaligrafy kaligrafy force-pushed the addExceptionWithInvalidDataInWhileLoops branch 3 times, most recently from 2235d48 to 110df3b Compare May 27, 2022 17:05
@tahini
Copy link
Collaborator

tahini commented May 27, 2022

Why changes in the m4 files? They make the builds fail on linux

@kaligrafy
Copy link
Collaborator Author

kaligrafy commented May 27, 2022

@greenscientist I could not run reconf or ./configure without auto changing the associated files in the m4 directory. Can you explain what is happening here? I removed the files for now, but I would like to know why they were changed.

@kaligrafy kaligrafy force-pushed the addExceptionWithInvalidDataInWhileLoops branch from 110df3b to 1fb8564 Compare May 27, 2022 17:55
@kaligrafy
Copy link
Collaborator Author

When I run autoreconf -i on macos, it outputs this and change the two files:
glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
glibtoolize: copying file 'm4/libtool.m4'
glibtoolize: copying file 'm4/ltversion.m4'

Copy link
Collaborator

@tahini tahini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have bad data lying around, I'll test this on monday.

@@ -19,6 +19,13 @@ namespace TrRouting
odTripsActivities.clear();
odTripsModes.clear();

accessNodesIdx.clear();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you merged with the last commit of v2c... Please rebase on v2c to remove this

@kaligrafy kaligrafy force-pushed the addExceptionWithInvalidDataInWhileLoops branch from 1fb8564 to 5012bac Compare May 27, 2022 20:20
the two while loops in forward and reverse journey can create memory leak (infinite push into a vector) when invalid data is found (like reverse travel times or incorrectly rounded/floored/ceiled travel time seconds that was imported as float, see #141, needs testing though to close issue
@kaligrafy kaligrafy force-pushed the addExceptionWithInvalidDataInWhileLoops branch from 5012bac to 3e050be Compare May 27, 2022 20:22
Copy link
Collaborator

@tahini tahini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with faulty data. Just make sure it is properly handled, and it's the right type of exception that is thrown (see comments)

NO_SERVICE_TO_DESTINATION
NO_SERVICE_TO_DESTINATION,
// Invalid data found, which could create memory leaks or incorrect results
INVALID_DATA
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are adding a new reason for no routing, so you should also add it

  1. in result_to_v1.cpp, in the noRoutingFoundResponse function, it should return an appropriate string message.
  2. In the API.yml file, in the reasons for no routing (search for NO_SERVICE_TO_DESTINATION)
  3. Is it possible to think of faulty data that could cause this problem to happen? If so, you could add a unit test for this reason (one that would fail with current branch and suceed now). If it is possible to at least describe the kind of data in a dummy unit test in csa_route_calculation_test.cpp, then someone could add a test later

{
public:
InvalidDataException(NoRoutingReason reason_) : std::exception(), reason(reason_) {};
NoRoutingReason getReason() const { return reason; };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm my preivous comment depending on the answer here: This is a new exception type, that will be caught by the catch-all clause in transit_routing_http_server and return a "Wrong or malformed query". In that case

  1. It's not really the query who's malformed, it's the data! The returned value will be counterintuitive to the caller
  2. It's technically not a NoRoutingReason. You could throw the NoRoutingFoundException with the INVALID_DATA reason, or if you want a new exception, you should put a new enum for those reasons, add it to the API and return a better error message to the user in those cases.

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

Successfully merging this pull request may close these issues.

None yet

2 participants