0

I have a server program(compile by g++) which is running. And I change some code and compile a new bin file. Without kill the running process, I mv the new created bin to overwrite the old one.

After a while, the server process crashed. Dose it relate to my replace action?

My server is an multi-thread high concurrent server. One crash is segfault, other one is deadlock. I print all parameters in the core dump file and pass them exactly same to the function which was crashed. But it is OK.

And I carefully watch all thread info in the deadlock core dump, I can not find it is an possibility to cause deadlock.

So I doubt the replacement will cause strange things

According to this question, if swap action is happen, it indeed will generate strange things

jean
  • 2,825
  • 2
  • 35
  • 72
  • Can you give us more information? Can you provide two sets of example code that exhibit the behaviour when one is swapped for the other? What is the crash? (segmentation fault?) What does a curse dump / debugger say? – Attie Mar 30 '18 at 11:21
  • I can't currently comment on technical details, but I've seen what you describe myself when replacing libraries or binaries. – Attie Mar 30 '18 at 14:41

2 Answers2

1

For a simple standard program, even if it is currently opened by the running process, moving a new file will first unlink the original file which will remain untouched apart from that.

But for long running servers, many things can happen: some fork new processes and occasionally some can even exec a new fresh version. In that case, you could have different versions running side by side which could or not be supported depending on the change.

Said differently, without more info on what is the server program, how it is designed to run and what was the change, the only answer I can give is maybe.

Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252
0

If you can make sure that you remove ONLY the bin file, and the bin file isn't used by any other process (such as some daemon). Then it doesn't relate to your replace action.

Yves
  • 11,597
  • 17
  • 83
  • 180
  • remove? what about replace? ... are you sure? I would have said "yes - it is quite possibly linked to the replace"... – Attie Mar 30 '18 at 09:50
  • @Attie If an executable file is running, you can remove, replace or do any other thing from the hard drive. Because it has been loaded into RAM. The OP said, he replaced the old bin file with the new one but he didn't execute the new one. – Yves Mar 30 '18 at 10:30
  • Sure - but what happens if the application is swapped out... does it go into swap, or is it "on disk", so simply thrown away? Then when an attempt is made to "swap" it back in, the file had changed, and thus the application crashes. – Attie Mar 30 '18 at 11:19
  • @Attie I had considered this kind of possibility. My server is 206 MB. However the machine memory is 8G. So it seems no necessary to swap the bin. But there is no way to make sure – jean Mar 30 '18 at 12:44
  • @Yves I have not remove it. I just mv the new one into the folder which old one locates. – jean Mar 30 '18 at 12:45
  • @jean I don't think you can really replace a running bin file with another bin file. Because "running" means that the bin file has been loaded into SWAP so that RAM can control it. your `mv` simply replace the bin file from the hard drive. – Yves Mar 31 '18 at 02:18