[BUG][FIX][SF] sqXWindow.c patch

David T. Lewis lewis at mail.msen.com
Fri Oct 6 04:01:44 UTC 2000


Bug: When running Squeak under Unix/Linux with the -xshm option, and
when using OSProcess to fork new Squeaks from the running Squeak image,
the VM exits with an X protocol error.

Cause: Following a Unix process fork, The shared memory segment used for
the connection to the X server was not properly detached from the child
process and replaced with a new shared memory for the child process.

Fix: Modified sqXWindow.c to permit correct handling of shared memory
segments following a process fork when the VM is run with the -xshm option.

The attached diff is relative to the sqXWindow.c source file in the
Squeak-2.8pre3.tar.gz source distribution.

The source code on SourceForge (which has the sqXWindow.c file split
into several source files) has also been updated to include this fix.

- Dave

p.s. This change also fixes the shared memory detach logic so that
shared memory segments are not left laying around if the VM process is
not shut down cleanly.

p.p.s. The bug was a side effect of my having added a "Squeak forking"
feature in OSProcess, and should not be attributed to Ian, who presumably
never intended the VM to be abused in this particular manner.

-------------- next part --------------
338a339
> static void shmExit(void);
487a489,495
> #ifdef USE_XSHM
>   if (stDisplayBitmap && useXshm)
>     {
>       stDisplayBitsIndex= -1;
>       shmExit();
>     }
> #endif
500a509,511
> #ifdef USE_XSHM
>     shmExit();
> #endif
1863a1875
>   shmctl(stShmInfo.shmid, IPC_RMID, 0);	/* Mark shmid for later removal	*/
1878d1889
<   shmctl(stShmInfo.shmid, IPC_RMID, 0);
1879a1891,1894
>   stShmInfo.shmseg= 0;
>   stShmInfo.shmid= 0;
>   stShmInfo.shmaddr= 0;
>   stShmInfo.readOnly= 0;
1887c1902,1905
<     stFree(stDisplayBitmap);
---
>     {
>       stFree(stDisplayBitmap);
>       stDisplayBitmap= 0;
>     }
1929c1947
<   if (useXshm)
---
>   if (useXshm && stShmInfo.shmid)


More information about the Squeak-dev mailing list