Daniel, no, that's not it. First, apport is always run as root. Second, if the os.open() fails, apport writes "cannot create lock file" into apport.log and exits. If you got "another apport instance is already running, aborting", then the flock() call failed. If it usually works, then I guess there really was another apport instance running at that time. If it generally fails, it should be reproducible with
Daniel, no, that's not it. First, apport is always run as root. Second, if the os.open() fails, apport writes "cannot create lock file" into apport.log and exits. If you got "another apport instance is already running, aborting", then the flock() call failed. If it usually works, then I guess there really was another apport instance running at that time. If it generally fails, it should be reproducible with
python -c "import os, fcntl; fd = os.open( '/var/lock/ .crash' , os.O_WRONLY| os.O_CREAT| os.O_NOFOLLOW) ; fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)"
Does that work for you?