From:Steve Adams
Date:06-Nov-2001 23:40
Subject:   Corrupting the log buffer

Oracle have actually gone to considerable lengths to attempt to ensure that log buffer corruptions do not happen. From 8i the redo copy latch is retained while the changes are applied to the data blocks so that the validity of the redo record can be confirmed before it is written to disk by LGWR. So even if an Oracle bug causes invalid redo to be generated, it will be marked as invalid in the redo stream before it gets written to the log files. Of course, recovery would just skip any redo that is marked as invalid.

The other way in which the log buffer might be corrupted is if an Oracle bug causes a pointer or offset to be corrupted so that data which ought to be copied into memory at another location tries to address part of the log buffer instead. This could also happen due to a hardware memory error, or a hacker attack. Oracle attempts to eliminate this risk using memory protection. See the mprotect() system call. If a memory page is marked PROT_NONE, then any attempt to read it will return EACCES despite the effective user id of the process being that of the owner of the shared memory segment.

Your code might be failing because of memory protection. If so, you should be able to work around it using mprotect(). However, I thought that the whole idea of using guard pages was to avoid using memory protection on the log buffer itself. So you might be making the mistake of hitting the guard page, rather than skipping over the first memory page into the log buffer itself. Failing that, it could just be a coding problem.

I am trying to read a memory location of the redo buffer. I do not seem to be having much luck. I did
1. oradebug ipc;
2. Used shmat() with the shmid to attach to the memory segment.
3. Used *ptr to look at the memory of log buffer.

Since the memory segment is owned by oracle I thought I could read/write the memory when I log on as oracle. I'll appreciate if you could give me some suggestions on this. I have been struggling with this for weeks. What I am trying to do is to simulate log buffer corruption, monitor how Oracle reacts to it, and analyze how it will affect the database (primary and standby).