It costs 3,000 gas and returns the 20-byte address of the recovered public key, or zero bytes (the zero address in Solidity) for invalid input such as v other than 27 or 28 or r and s out of range. It does not enforce low-S, so a contract that uses signatures as unique identifiers must reject s above n/2 itself (EIP-2 applied that rule to transactions only).
Safe use: always compare the result with the expected signer and reject the zero address, check a nonce or deadline in the signed data to prevent replay, hash EIP-191 or EIP-712 data rather than raw values, and use ERC-1271 for smart-contract accounts. OpenZeppelin's ECDSA.recover and SignatureChecker wrap these checks.