Attempt to fix race condition when attr is null. Fixes #1366