11.01.2013 Views

IBM AIX Continuous Availability Features - IBM Redbooks

IBM AIX Continuous Availability Features - IBM Redbooks

IBM AIX Continuous Availability Features - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

strlen() at 0xd010da00<br />

_doprnt(??, ??, ??) at 0xd0126350<br />

printf(0x200003f4, 0x30000000, 0xffffffff, 0x2ff47600, 0x0, 0x0, 0x0, 0x0) at<br />

0xd011eabc<br />

main(argc = 2, argv = 0x2ff22554), line 126 in "ukey1.c"<br />

(dbx)q<br />

#<br />

Notice that a segmentation fault occurred at strlen(), which was trying to read shared memory<br />

and calculate its size. Because read permission was not provided, it caused SIGSEGV.<br />

Next, we gave the child process read (no-write) access to the shared memory segment and<br />

executed the code as shown in Example 3-33.<br />

Example 3-33 Program with read access to shared segment<br />

# ./ukey1 read<br />

parent:pagesize=4096<br />

child:data=0x30000000<br />

child :READ1 =[]<br />

parent:READ1 =[]<br />

parent:WRITE1=[ABCD]<br />

# ls core<br />

core<br />

# dbx ukey1 core<br />

Type 'help' for help.<br />

[using memory image in core]<br />

reading symbolic information ...<br />

Segmentation fault in noname.strcpy [ukey1] at 0x10001004<br />

0x10001004 (strcpy+0x4) 99030000 stb r8,0x0(r3)<br />

(dbx) where<br />

noname.strcpy() at 0x10001004<br />

main(argc = 2, argv = 0x2ff2255c), line 127 in "ukey1.c"<br />

(dbx)q<br />

#<br />

Notice that a segmentation fault occurred at the strcpy() function, which was trying to write to<br />

shared memory. The strlen() function did not fail this time, because we gave read access to<br />

the shared page. However, the child process does not have write access to strcpy(), which<br />

caused SIGSEGV.<br />

We executed the program by giving read and write access, as shown in Example 3-34 on<br />

page 106.<br />

Example 3-34 Program gets read and write access to shared segment<br />

# ./ukey1 readwrite<br />

parent:pagesize=4096<br />

child:data=0x30000000<br />

child :READ1 =[]<br />

child :WRITE1=[abcd]<br />

parent:READ1 =[abcd]<br />

parent:WRITE1=[ABCD]<br />

child :READ2 =[abcdABCD]<br />

child :WRITE2=[efgh]<br />

106 <strong>IBM</strong> <strong>AIX</strong> <strong>Continuous</strong> <strong>Availability</strong> <strong>Features</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!