You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crash when Writing near-miss point merged wpt files #44
This just doesn't seem to make sense.
All strings involved are pretty well-defined, with no opportunities to have zero, negative, or humongous lengths. Just shouldn't be happening, but here it is...
To unpack this a bit...
First, when still in single-threaded operation, Route objects (each containing a minimum of 5 strings + any alt_route_names) are copied into the all_routes list. Would this present a problem with -t 1? Possibly try pointers.
Second, args.nmpmergepath is passed to NmpMergedThread. This can be passed as a pointer instead.
New Route object created from front of list. Again, try pointers?
nmpmergepath + "/" + r.region->code passed to r.write_nmp_merged. Can't pass by reference here, obviously.
filename gets concatenated a few times.
for (std::string a : w.data->alt_labels) &a instead
Points 1 & 3 -> no crashes while Writing near-miss point merged wpt files, in 100 runs.
Putting std::to_string back (reverting point 7) would mean more clean & concise code. Seems to run a bit faster too.
Just gotta do 100 trials to make sure the bugs don't creep back in. :)
Edit: And it's back. Attempt 15 of 29 so far. This means returning to sprintf, and doing even more trials to make sure things work.
Still crashes. 3 times out of 400.
No Bash output observed, so I can't confirm whether the issue is still std::length_error / basic_string::_M_create. If it is, it's points 4 & 5, path & filename. Feh.
I'll wait till I catch it in the act again...
script captured all bash output for 400 runs. 7 crashes while reading WPTs; one crash writing nmp_merged. Not std::length_error / basic_string::_M_create, but a core dump similar to what's in #54. *** Error in `./siteupdate': free(): invalid pointer: 0x00007ffdd02ca250 ***, etc.
I'm not deleteing anything, other than the threads themselves after completion, which should not be a problem. Variables -- strings & standard containers for the most part -- just reach the end of their lifespans & are destructed however C++ destroys them.
Either something wrong with my RAM, or something is getting fouled up behind the scenes in ways I can't quite see by multiple threads writing to stuff.
The saner approach would be to assume the latter if there's something I've confirmed needs fixing.
Address #56, keep testing, and see where that leads me.
Seems one time I saw something funky where a while (foo->size()) loop would continue, size would then be 0, and wacky antics would ensue upon trying to construct an object from the front.
But this construction should happen (and fail) before all_routes->pop_front(). We're inside a locked mutex.
I'll try different ways of iterating anyway; I'm running out of ideas...
void NmpMergedThread
( std::list<Route*> *all_routes,
std::mutex *mtx,
std::string *nmpmergepath
)
{ while (all_routes->size()) // 2 or more threads see size() of 1, and enter the while loop
{ mtx->lock(); // Thread 1 gets here first, locks mtx, and does its thing
Route *r(all_routes->front()); // Thread 2 gets here, still thinking size() is 1, and that there are objects in all_routes// undefined behavior when trying to access front()
all_routes->pop_front(); // More undefined behavior due to empty container// Maybe trying to free an invalid pointer?// I don't know man, I didn't do it.
mtx->unlock();
r->write_nmp_merged
(*nmpmergepath + "/" + r->region->code);
}
}
If that's the case, I have not solved the problem but only made it less probable, changing to:
void NmpMergedThread
( std::list<HighwaySystem*> *hs_list,
std::mutex *mtx,
std::string *nmpmergepath
)
{ while (hs_list->size()) // 2 or more threads see size() of 1, and enter the while loop
{ mtx->lock(); // Thread 1 gets here first, locks mtx, and does its thing
HighwaySystem *h(hs_list->front()); // Thread 2 gets here, still thinking size() is 1, and that there are objects in hs_list// undefined behavior when trying to access front()
hs_list->pop_front(); // More undefined behavior due to empty container// Maybe trying to free an invalid pointer?// I don't know man, I didn't do it.
mtx->unlock();
for (Route &r : h->route_list)
r.write_nmp_merged
(*nmpmergepath + "/" + r.region->code);
}
}
Thus it may be a bit premature to close this issue, even though I've not yet observed crashes, in 121 trials w/8 threads so far.
Solving the problem may be as simple as putting in another check, an if (foo->size()) once the mutex is locked.
I may be better off looking into that while looking into the Computing stats crash (#54), the only really visible failure mode at the moment.
Above hypothesis checks out; if statements appear to have stopped crashes in other threads.
Even with no further crashes in several hundred more runs, this is the safe course of action to take.
It's back!
Or rather, nothing has changed here in a while IIRC, but running with 16 threads on lab2 gives more opportunity to observe this.
No core dump or any text in bash to let us know what's going on.
Edit: Using crashlog.sh on BiggaTomato, no crashes in 100 runs, whereas it's fairly common on lab2. My thinking is that with 16 threads being handled by only 4 cores on BiggaTomato, there's less true parallelism, and less opportunity for wacky hijinks.
Now this is interesting... On lab2, one thread appeared to get caught in an infinite loop, CPU @ 100%, with the other 15 CPUs @ 0%.
May be best to tackle the other threads before this one...
Changed from a "modify the list" technique to a "modify the iterator" technique.
Siteupdate has now been running in a loop on lab2 for > 38 hours & 1313 passes now, with no crashes. Going to re-close this.
See #58 (comment) and forum post.
Activity
yakra commentedon Jan 16, 2019
While the error in the OP is pretty common, I've only ever seen this once IIRC.
yakra commentedon Jan 23, 2019
This just doesn't seem to make sense.
All strings involved are pretty well-defined, with no opportunities to have zero, negative, or humongous lengths. Just shouldn't be happening, but here it is...
To unpack this a bit...
-t 1? Possibly try pointers.yakra commentedon Jan 23, 2019
Addressed points 2 and 6. Crashes are still happening, 4 runs out of 40.
yakra commentedon Jan 23, 2019
Point 7 -> crashes are still happening, 6 attempts out of 100. Comparable to the 5/100 I got before attempting changes.
yakra commentedon Jan 24, 2019
Points 1 & 3 -> no crashes while Writing near-miss point merged wpt files, in 100 runs.
Putting std::to_string back (reverting point 7) would mean more clean & concise code. Seems to run a bit faster too.
Just gotta do 100 trials to make sure the bugs don't creep back in. :)
Edit: And it's back. Attempt 15 of 29 so far. This means returning to sprintf, and doing even more trials to make sure things work.
yakra commentedon Jan 24, 2019
Still crashes. 3 times out of 400.
No Bash output observed, so I can't confirm whether the issue is still std::length_error / basic_string::_M_create. If it is, it's points 4 & 5, path & filename. Feh.
I'll wait till I catch it in the act again...
yakra commentedon Jan 25, 2019
scriptcaptured all bash output for 400 runs. 7 crashes while reading WPTs; one crash writing nmp_merged. Notstd::length_error/basic_string::_M_create, but a core dump similar to what's in #54.*** Error in `./siteupdate': free(): invalid pointer: 0x00007ffdd02ca250 ***, etc.I'm not
deleteing anything, other than the threads themselves after completion, which should not be a problem. Variables -- strings & standard containers for the most part -- just reach the end of their lifespans & are destructed however C++ destroys them.Either something wrong with my RAM, or something is getting fouled up behind the scenes in ways I can't quite see by multiple threads writing to stuff.
The saner approach would be to assume the latter if there's something I've confirmed needs fixing.
Address #56, keep testing, and see where that leads me.
[-]std::length_error / basic_string::_M_create[/-][+]crash when Writing near-miss point merged wpt files[/+]yakra commentedon Jan 26, 2019
Makes sense to take the 3 current bugs chronologically:
#44, #55, #54
yakra commentedon Jan 26, 2019
Seen 2 core dumps now. In both cases, the pointer is in the stack.
Are these the pointers to my threads, is deleting them a bad idea?
yakra commentedon Jan 26, 2019
Ideas:
std::list<Route*> *all_routes?Try not deleting threads.No dice.Learn awk... Only relaunch siteupdate when there's no crashyakra commentedon Jan 26, 2019
for posterity:
yakra commentedon Jan 26, 2019
Seems one time I saw something funky where a
while (foo->size())loop would continue, size would then be 0, and wacky antics would ensue upon trying to construct an object from the front.But this construction should happen (and fail) before
all_routes->pop_front(). We're inside a locked mutex.I'll try different ways of iterating anyway; I'm running out of ideas...
yakra commentedon Jan 26, 2019
Current hypothesis, here's what's going on:
If that's the case, I have not solved the problem but only made it less probable, changing to:
Thus it may be a bit premature to close this issue, even though I've not yet observed crashes, in 121 trials w/8 threads so far.
Solving the problem may be as simple as putting in another check, an
if (foo->size())once the mutex is locked.I may be better off looking into that while looking into the Computing stats crash (#54), the only really visible failure mode at the moment.
yakra commentedon Jan 27, 2019
Above hypothesis checks out;
ifstatements appear to have stopped crashes in other threads.Even with no further crashes in several hundred more runs, this is the safe course of action to take.
yakra commentedon Jan 27, 2019
Related issues:
#56 ReadWptThread
#44 NmpMergedThread
#55 ReadListThread
#58 ConcAugThread
#54 ComputeStatsThread
#59 UserLogThread
yakra commentedon Jun 3, 2019
It's back!
Or rather, nothing has changed here in a while IIRC, but running with 16 threads on lab2 gives more opportunity to observe this.
No core dump or any text in bash to let us know what's going on.
Edit: Using crashlog.sh on BiggaTomato, no crashes in 100 runs, whereas it's fairly common on lab2. My thinking is that with 16 threads being handled by only 4 cores on BiggaTomato, there's less true parallelism, and less opportunity for wacky hijinks.
yakra commentedon Jun 7, 2019
Now this is interesting... On lab2, one thread appeared to get caught in an infinite loop, CPU @ 100%, with the other 15 CPUs @ 0%.
May be best to tackle the other threads before this one...
yakra commentedon Jun 23, 2019
Changed from a "modify the list" technique to a "modify the iterator" technique.
Siteupdate has now been running in a loop on lab2 for > 38 hours & 1313 passes now, with no crashes. Going to re-close this.
See #58 (comment) and forum post.