Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you "avoid" a SIGSEGV?

I'm writing a client-server app, in which the client has a determined memory address from the server side.

If something goes wrong and the server needs to be reestarted the address the client has is not valid anymore. When using a function using that invalid info a SIGSEGV will be sent to the server as the address may not be its anymore.

How can the server protect itself from a SIGSEGV and continue accepting connections and operating normally? Is there any way not to crash the server when this happens?

Thank you very much.

like image 463
Jane Michaels Avatar asked Dec 17 '22 01:12

Jane Michaels


1 Answers

The client should not send a memory address to the server, period. If the client needs a reference to server resources, the server should provide it with some sort of handle that the server can translate to an address, but which isn't directly dereferenced.

In your case, the server restart has probably rendered the client's handle invalid. The server should notice this and return a well-understood error code to the client telling it to get a new resource handle.

like image 180
JSBձոգչ Avatar answered Dec 28 '22 23:12

JSBձոգչ