I teach a course in C++. Often, students submit a homework assignment that works well in their computer (they send me a screenshot showing that it compiles and runs perfectly), but when I run the assignment on my computer, I get a "segmentation fault". This is, most probably, due to some pointer-related bug or an uninitialized variable, that results in an "undefined behavior": in the students' computer this "undefined behavior" happens to work fine, but it is still an error.
When I tell this to the students, they do not know how to work towards solving the problem, since they cannot even see it on their computer. There are 160 students (with 2 instructors and 3 TAs) in the course, and I do not have time to debug their submissions on my computer, or to give them my computer for debugging.
One solution is to have a shared server, and have all students submit their exercises in the same server, so that everyone - including me - work in exactly the same environment. However, currently I do not have such a server so students work on their own computers, which can be Windows, Linux or Mac.
Additionally, having an identical environment for everyone is not a complete solution, since it is still possible that a submission happens to work well on this identical environment, despite it having an "undefined behaviour" bug. An identical environment thus only guarantees that, if the students do not see an error, then I will not see it too.
How can I help students debug their code in this situation?
EDIT: A related problem is that, when the students submit such a solution and I tell them they have a bug, they say "the bug is in your computer! See, my code works well on my computer!". So a related question is: how can I explain to them that there is a bug in their code, even when they do not see it?