ad-freiburg / pfaedle

Precise map-matching for public transit feeds. Generates high-quality GTFS shapes from OSM data.
GNU General Public License v3.0
208 stars 29 forks source link

Question about strange resize of maxCosts in Router.tpp #48

Closed aheld84 closed 1 year ago

aheld84 commented 1 year ago

Dear pfaedle developers,

I ran into some problems with segmentation faults which turned out to be out of bounds errors using the -D_GLIBCXX_ASSERTIONS option when routing with very few edge candidates. I think I could track the cause down to this line

https://github.com/ad-freiburg/pfaedle/blob/c27f8a852fe26c5c1fc782890375e73e6c14bd68/src/pfaedle/router/Router.tpp#L39

which I really don't understand. It is causing an out of bounds error later when the maxCosts are set in this line:

https://github.com/ad-freiburg/pfaedle/blob/c27f8a852fe26c5c1fc782890375e73e6c14bd68/src/pfaedle/router/Router.tpp#L91

Removing the resize fixed my problems. Might it be the case that the resize is a remnant of some previous development stage where maxCosts were set per edge candidate and not per hop and this line was refactored in the wrong way instead of removing it?

All the best Alex

patrickbr commented 1 year ago

Might it be the case that the resize is a remnant of some previous development stage where maxCosts were set per edge candidate and not per hop and this line was refactored in the wrong way instead of removing it?

Indeed, maxCosts here does track the maximum cost across all candidates, so this line makes no sense. This seems to be an initialization of maxCosts to 0 gone wrong. Commit to fix this follows.