Debugging a submission that works well on student's computer but not on my computer 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?
You've said that having an identical environment for everyone would be an incomplete solution, since students' code could still work "by accident" in that environment. One option would be to provide access to two or more sufficiently different environments which would be the same for everyone; such environments could be provided in several ways, for example:


Distribute virtual machine images, with instructions for how students can use them to test their code.
Provide access to virtual machines through a paid service; for example, Codio is specifically designed for use in CS education.
There are some web services such as repl.it, which compile and run your code, and show the results in a console.
Some universities have student-run computing societies offering accounts for students on a shared server.
Different environments may already be available if students are on campus, and the campus has enough different computer labs open for student use at some times.


To catch undefined behaviour when grading submissions, you could test their code in the same two (or more) environments that students have been encouraged to use. Assuming you have a script that can automatically run all submissions, it shouldn't be a lot of extra work to run that script twice.



Another option is to provide students with a software tool which can detect and report undefined behaviour, as discussed in this Q&amp;A on Stack Overflow. Such a tool could also be used to give feedback to students whose submissions fail on your machine during grading; although static analysis and other techniques won't generally be able to detect all kinds of undefined behaviour, the kinds they do detect should cover most or all of the mistakes that students are likely to make.