Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.4k stars 3.39k forks source link

Report LUA errors #3084

Open emiltin opened 8 years ago

emiltin commented 8 years ago

Working on rebasing/updating ##2032, I found that LUA errors (eg. syntax errors or nil objects) are not reported when running cucumber tests, nor are there any reference to LUA file or line number. All I get is a generic 'osrm-extract killed'. This makes working on LUA profiles and refactoring hard.

Example

1) Scenario: Car - Use motorway_link when reasonable - features/car/link.feature:10
   Step: When I route I should get - features/car/link.feature:28
   Step Definition: features/step_definitions/routing.js:4
   Message:
     Error: osrm-extract killed by signal SIGABRT: /Users/emil/code/osrm-backend/build/osrm-extract --profile /Users/emil/code/osrm-backend/profiles/car.lua /Users/emil/code/osrm-backend/test/cache/car/link.feature/0fe4f83497f36d2320eb952191ee01f7/fe94ae7c9b17d24c18f1cf1c8995ef10/10_car_use_motorway_link_when_reasonable.osm
         at /Users/emil/code/osrm-backend/features/support/data.js:174:37
         at ChildProcess.exithandler (child_process.js:209:5)
         at emitTwo (events.js:100:13)
         at ChildProcess.emit (events.js:185:7)
         at maybeClose (internal/child_process.js:827:16)
         at Socket.<anonymous> (internal/child_process.js:319:11)
         at emitOne (events.js:90:13)
         at Socket.emit (events.js:182:7)
         at Pipe._onclose (net.js:475:12)
daniel-j-h commented 8 years ago

Yep, this is an issue. Makes it hard to implement features in Lua.

What could help is https://github.com/Project-OSRM/osrm-backend/issues/3013 with proper error handling. At the moment there are just classes of errors that are hard to impossible to catch for us, e.g. assigning Lua nil to a bounded object's std::string member (undefined behavior, hopefully just crashes).

daniel-j-h commented 7 years ago

Now that https://github.com/Project-OSRM/osrm-backend/pull/3382 is more or less complete, we can revisit this ticket. @karenzshea would you be so kind to test what happens if you add syntax errors to the car profile run the cucumber test suite.

From what I'm reading here we should get an exception: https://sol2.readthedocs.io/en/latest/errors.html

daniel-j-h commented 7 years ago

Just had a look when rebasing the sol2 branch, this is the error message from the exception sol2 throws:

terminate called after throwing an instance of 'sol::error' what(): lua: error: /tmp/osrm-backend/profiles/car.lua:13: syntax error near 'barrier_whitelist'

I put some garbage next to the barrier whitelist. Not too bad in my opinion.

But this is only in test/logs/car/, the Cucumber output does not show this directly.

Next action here:

On error Cucumber has to check and propagate the message osrm-extract's output to the user.