How to fill stucco gaps around light fixture
The extension screws into the existing box. The light fixture screws into the extension. All wiring is now inside the box and extension, protected from lots of problems. Once you have done that, you can fill the cracks with or with some other filler compound.