I've been trying to get over this problem for some time now, without success. I use type intptr_t as you advised:
Then I have a loop with mprotect:
It failes with "Invalid argument" every time the address is not aligned to page size (as expected) but also fails with "Not enough memory" when the (ptr2-i) is properly aligned. Any more ideas?
Hi,
Does anyone seen this error before..
kernel: ENOMEM in journal_alloc_journal_head, retrying.
I encounter this problem on IBM eServers where when the above error appears usually the machine is dead or hanged. Unless a hard reboot is been done. Is this something have to do with the memory... (1 Reply)
When run it, segment fault.
What is wrong?
#include <stdio.h>
#include <stdlib.h>
const int max =20;
//****************************************************
// Input Matrix
//****************************************************
void inMatrixAA(int *AA, int row, int col)... (9 Replies)
I do have 2 different segment network which different platform on each segment. E.g. 20 segment, Windows OS can talk to Unix OS and 21 segment practice same rule. Further more, Windows OS from 20 segment can talk to 21 segment other OS but only the UNIX OS in 20 segment fail to talk to 21 segment.... (3 Replies)
I need help in removing a leading zero in a particular position.
For eg.: XYZ*04567472*0099*020091231*0123*0.12
In the above line, I want to replace "*0123" with "123" and "0.12" with ".12". I want to remove the leading zero only in position number 4 and 5 (the bolded segments)
I was able... (10 Replies)
I mean, I malloc a segment of memory, maybe 1k maybe 20bytes.. assume the pointer is pMem How can I know the content pMem refered is all Zero or \0 . I know memcmp but the second parameter should another memory address... thanx (4 Replies)
Hi to all.
I'm reciving a "Segment violation" error from this code and I don't know why.
void insertAtEnd(NodeType *pList) {
char element;
printf("Introduce a element: \n");
setbuf(stdin, NULL);
scanf("%c", &element);
//Find the end of the list;
while... (4 Replies)
Hi,
Whether the following piece of code is placed in the read-only memory of code (text) segment or data segment?
char *a = "Hello";
I am getting two different answers while searching in google :( that's why the confusion is (7 Replies)
I always get segment fault, why? can sb help me and modify it, I have spend on much time on
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
#define MAX 10
pthread_t thread;
void *thread1()
{
int *a;
int i, n;
... (1 Reply)
Discussion started by: yanglei_fage
1 Replies
LEARN ABOUT ULTRIX
mprotect
mprotect(2) System Calls Manual mprotect(2)Name
mprotect - memory protection control
Syntax
#include <sys/mman.h>
#include <sys/types.h>
int mprotect (addr, len, prot)
caddr_t addr;
int len, prot;
Description
The system call changes the protection of portions of an application program's data memory. Protection is performed on page cluster bound-
aries. The default protection for data memory on process invocation is user READ/WRITE. The addr argument is the beginning address of the
data block and must fall on a page cluster boundary.
The len argument is the length of the data block, in bytes. The length of the block is rounded up to a cluster boundary, and the size of
the block to be protected is returned.
The prot argument is the requested protection for the block of memory. Protection values affect only the user process. Protection values
are defined in <mman.h> as:
/* protections are chosen from these bits, ORed together */
#define PROT_READ 0x1 /* pages can be read */
#define PROT_WRITE 0x2 /* pages can be written */
#define PROT_EXEC 0x4 /* pages can be executed */
Setting the prot argument to zero (0) indicates that the process cannot reference the memory block, without causing a fault.
A protected page faults if the protection is violated, and a SIGBUS signal is issued. If the process has a handler defined for the SIGBUS
signal, the code parameter, described in and is used to pass in the virtual address that faulted.
Restrictions
The page cluster size may change in future versions of ULTRIX. As a result, should be used to determine the correct len argument, and or
should be used to determine the correct addr argument.
If the user handles a SIGBUS signal, the signal handler must either abort the process or correct the condition that caused the protection
fault (SIGBUS). If some corrective action is not taken, an infinite loop results because the faulting instruction is restarted. If the
user permits the default SIGBUS handler to be used, the process aborts if a referenced page causes a fault.
The VAX architecture makes the following implications; PROT_WRITE implies (PROT_WRITE | PROT_READ | PROT_EXEC), and PROT_READ implies
(PROT_READ | PROT_EXEC).
Only the application can change the call's private data space. This means that attempts to change text, shared memory, or stack space
causes a EACCES failure.
Return Values
Upon successful completion, the size of the protected memory block, in bytes, is returned. Otherwise, a value of -1 is returned and errno
is set to indicate the error.
Diagnostics
The call fails under the following conditions:
[EALIGN] The addr argument is not on a cluster boundary.
[EINVAL] The prot argument is not a valid protection mask.
[EACCES] The memory block is not fully contained within private data space.
See Alsogetpagesize(2), sbrk(2), sigvec(2), malloc(3), signal(3)mprotect(2)