Shared Memory corruption issue