I'm reading the Function modifiers section of solidity doc.

contract Mutex {
bool locked;
modifier noReentrancy() {
    locked = true;
    locked = false;

/// This function is protected by a mutex, which means that
/// reentrant calls from within msg.sender.call cannot call f again.
/// The `return 7` statement assigns 7 to the return value but still
/// executes the statement `locked = false` in the modifier.
function f() noReentrancy returns (uint) {
    return 7;


From that example I'm confused that what it means by msg.sender.call()? What function does call() call exactly? The corresponding comment says

reentrant calls from within msg.sender.call cannot call f again

does it mean call() is calling f() itself? If so why is that, is there any documentation clarify so? Thanks in advance!

1 Answer 1


Mutex contract has one modifier which is noReentrancy. This modifier has one bool variable which set to false. When you execute the function f() in Mutex contract it will execute for the first time since condition satisfies. Then it will assign the bool variable as true. So for the second time when you execute this function f(), the condition gets failed and you cant execute the function f().

The call() method was used to call the function in the another contract. For example


For more reference, you can check solidity address

  • 1
    Thanks for the answer, 'The call() method was used to call the function in the another contract.' - but what exact function in that contract does it call and how do I know what it is? Is the fallback function getting called, or can we determine by the arguments provided to call()?
    – nrek
    Sep 24, 2017 at 23:08
  • call() method will invoke the fallback function. And this can take arguments as a string which can be passed to that function as data. contract NameReg { bytes32 public nn; bytes public calldata; function register(bytes32 name) { nn = name; } function() { calldata = msg.data; } function doesNotCallRegister() { this.call("register", "MyName"); } } This contract this.call() method invokes the fallback funciton with data as register and myname which can be accessed using msg.data in fallback function. Sep 25, 2017 at 3:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.