in reply to can't lock an object from a base class in a derived class

You're using two different variables. In mybase you declare a lexical variable named $mode :

my $mode : shared;

... but in the package derived, you try to access a global variable named $mode:

$mybase::mode = 1;

The two variables are different (and the lexical variable is unreachable from derived anyway) and hence Perl complains.