Patches for ILU 2.0alpha13

Revised $Date: 1998/11/24 17:56:17 $ GMT

About Patches

Getting the "patch" program

The program "patch" is distributed from a number of places, and odds are you already have it on your system. If not, try ftp://gatekeeper.dec.com/pub/BSD/FreeBSD/FreeBSD-current/src/gnu/usr.bin/patch/ for the sources. On Windows platforms, there appears to be a version in the Win32 distribution of the GNU tools. There are several different UNIX versions of patch. Older versions won't be able to handle raw HTML as input, so you may want to upgrade if you have an old version. To check the version, try typing "patch -v" at a command line. If your patch program doesn't like that, or if the version printed out is less than 2.1, you will probably want to fetch the newer version and build it.

Applying a patch

To patch your sources, copy any patch listed below into a patch file. If you're going to apply more than one, apply them in order, and put each patch in a separate patch file. Then change your working directory to the top of the ILU source tree (ILUSRC), and use the command "patch -p0", (that's a zero) redirecting standard input to come from this file. For example, if you had put the ILU sources in /usr/local/ilu/src, and had put the patch in /usr/local/ilu/src/this-patch, you'd type
  % cd /usr/local/ilu/src
  % patch -p0 < /usr/local/ilu/src/this-patch
  [...various output from the patch program...]
  %
NOTE: On a fresh (unpatched) distribution, it usually works to just feed this entire patches.html file into the patch program, e.g. patch -l -p0 < patches.html
WARNING: copying these files from a browser may produce problems with some patches due to a conversion of tabs to spaces. If you have a patch application fail, try specifying the -l switch to patch. Also, when ftp'ing this page, use binary transfer. On Windows, some patches may be reported as malformed if you transfer the file in ascii mode. On UNIX, some patch versions may object to having carriage returns in the file, so if you observe problems, check to see that some intermediate step did not insert carriage returns.

Actual Patches


  • From Joachim Achtzehnter (joachim@mercury.bc.ca): ``There are a number of memory leaks in the pickle support of ILU's common lisp mapping. Anybody making heavy use of pickles in Lisp will see their process grow to a huge size very quickly. The attached patches for ilu-lisp-skin.c and ilu-kernel.lisp seem to fix all leaks we have encountered.''

    *** 1.43	1998/10/28 05:03:09
    --- runtime/lisp/ilu-kernel.lisp	1998/11/06 00:26:07
    ***************
    *** 569,575 ****
      (define-c-function ilu_write-pickle
          "write the type tag to the pickle, and allocate space"
        "ilu_WritePickle"
    !   (:ilu-call :cardinal :constant-string :ilu-kerr) :void)
      
      #+ilu-pickle
      (define-c-function ilu_read-pickle
    --- 569,575 ----
      (define-c-function ilu_write-pickle
          "write the type tag to the pickle, and allocate space"
        "ilu_WritePickle"
    !   (:ilu-call :cardinal :string :ilu-kerr) :void)
      
      #+ilu-pickle
      (define-c-function ilu_read-pickle
    *** 1.21	1998/10/28 05:03:09
    --- runtime/lisp/ilu-lisp-skin.c	1998/11/06 00:26:06
    ***************
    *** 931,936 ****
    --- 931,937 ----
        };
        bv->data = p.pi_bytes;
        bv->len = p.pi_len;
    +   ilu_free(call);
        return bv;
      }
      
    ***************
    *** 938,943 ****
    --- 939,945 ----
        ilulisp_EndDecodePickle (ilu_Call call, ilu_Error *err)
      {
        ilu_EndPickle(call, ILU_NIL, err);
    +   ilu_free(call);
      }
      
      #ifdef IIOP_PROTOCOL
    

  • A rare race condition on finalization of Python objects can lead to "object has no ilu_Server" messages. This patch removes the race condition.

    *** 1.263	1998/10/26 23:41:04
    --- runtime/python/iluPrmodule.c	1998/11/07 02:40:38
    ***************
    *** 1643,1659 ****
            ilu_Class kclass;
      
            if ((iv = iv_New()) == 0)
    !     return 0;
            if ((kclass = getKernelClass(inst->in_class)) == 0)
    !     return 0;
            ((IvObject *) iv)->kclass = kclass;
            if (PyDict_SetItemString(inst->in_dict,
    !                    nameVarInstVars, iv) < 0)
    !     {
    !       Py_DECREF(iv);
    !       return 0;
    !     }
    !       Py_DECREF(iv); /* let dictionary have only reference */
          }
        else if (!iv_Check(iv))
          {
    --- 1643,1660 ----
            ilu_Class kclass;
      
            if ((iv = iv_New()) == 0)
    ! 	return 0;
            if ((kclass = getKernelClass(inst->in_class)) == 0)
    ! 	return 0;
            ((IvObject *) iv)->kclass = kclass;
    +       ((IvObject *) iv)->pyobj = (void *) inst;
            if (PyDict_SetItemString(inst->in_dict,
    ! 			       nameVarInstVars, iv) < 0)
    ! 	{
    ! 	  Py_DECREF(iv);
    ! 	  return 0;
    ! 	}
    !       Py_DECREF(iv);		/* let dictionary have only reference */
          }
        else if (!iv_Check(iv))
          {
    ***************
    *** 1793,1799 ****
        PyInstanceObject *inst = (PyInstanceObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex); /* non-blocking */
        ilu_Class cl = ilu_ClassOfObject(kobj); /* non-blocking */
      
    !   if (inst != ILU_NIL && ((!ilu_TrueInstanceP(kobj)) || ilu_CollectibleP(cl))) /* non-blocking */
          {
            /*
            fprintf (stderr, "*** ILU kernel is %s in <%s> (0x%x, %s, %d)\n", vi ? "interested" : "not interested",
    --- 1794,1800 ----
        PyInstanceObject *inst = (PyInstanceObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex); /* non-blocking */
        ilu_Class cl = ilu_ClassOfObject(kobj); /* non-blocking */
      
    !   if (inst != ILU_NIL && (Py_COUNT(inst) > 0) && ((!ilu_TrueInstanceP(kobj)) || ilu_CollectibleP(cl))) /* non-blocking */
          {
            /*
            fprintf (stderr, "*** ILU kernel is %s in <%s> (0x%x, %s, %d)\n", vi ? "interested" : "not interested",
    ***************
    *** 2035,2041 ****
        ilu_Server    kserver = ilu_ServerOfObject(kobj);
        PyObject *    pyobj;
      
    !   if ((pyobj = (PyObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex)) == 0)
          {
            if ((pyobj = createSurrogateInstance(kobj)) == 0) {
          ilu_ExitServer(kserver, kclass);
    --- 2036,2043 ----
        ilu_Server    kserver = ilu_ServerOfObject(kobj);
        PyObject *    pyobj;
      
    !   if (((pyobj = (PyObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex)) == 0) ||
    !       (Py_COUNT(pyobj) < 1))
          {
            if ((pyobj = createSurrogateInstance(kobj)) == 0) {
          ilu_ExitServer(kserver, kclass);
    ***************
    *** 2107,2115 ****
          Py_INCREF(Py_None);
          return Py_None;
        } else {
    !     if ((pyobj = (PyObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex)) == 0) {      /* non-blocking */
    !       pyobj = Py_None;
    !     };
          Py_INCREF(pyobj);
          if ((pyobj != Py_None) && (NewObjects != ILU_NIL)) {
            removeObjFromList (NewObjects, pyobj);
    --- 2109,2119 ----
          Py_INCREF(Py_None);
          return Py_None;
        } else {
    !     if (((pyobj = (PyObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex)) == 0)	/* non-blocking */
    ! 	|| (Py_COUNT(pyobj) < 1))
    !       {
    ! 	pyobj = Py_None;
    !       };
          Py_INCREF(pyobj);
          if ((pyobj != Py_None) && (NewObjects != ILU_NIL)) {
            removeObjFromList (NewObjects, pyobj);
    ***************
    *** 2151,2159 ****
          ILU_HANDLED(kerr);
          return 0;
        } else {
    !     if ((pyobj = (PyObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex)) == 0) {
            if ((pyobj = createSurrogateInstance(kobj)) == 0)
    !     return 0;
            CALL_KERNEL(ilupython_threaded_operation,
                ilu_RegisterLSO(kobj, kclass, (void *) pyobj, _ilupython_LangIndex, &kerr));
            /* DM 24.4.97: although the Python reference is stored here away,
    --- 2155,2164 ----
          ILU_HANDLED(kerr);
          return 0;
        } else {
    !     if (((pyobj = (PyObject *) ilu_GetLanguageSpecificObject(kobj, _ilupython_LangIndex)) == 0) ||
    ! 	(Py_COUNT(pyobj) < 1)) {
            if ((pyobj = createSurrogateInstance(kobj)) == 0)
    ! 	return 0;
            CALL_KERNEL(ilupython_threaded_operation,
                ilu_RegisterLSO(kobj, kclass, (void *) pyobj, _ilupython_LangIndex, &kerr));
            /* DM 24.4.97: although the Python reference is stored here away,
    *** 1.7	1998/10/09 21:44:37
    --- runtime/python/ivobject.h	1998/11/07 02:40:34
    ***************
    *** 40,45 ****
    --- 40,46 ----
      	ilu_Object	kobj;
      	char *		publish_proof;
      	long		creatorPid;
    + 	void *		pyobj;
      } IvObject;
      
      extern PyTypeObject	Iv_Type;
    *** 1.18	1998/10/26 23:41:23
    --- runtime/python/ivobject.c	1998/11/07 02:40:33
    ***************
    *** 79,85 ****
        CALL_KERNEL(ilupython_threaded_operation, ilu_EnterServer(iv->kserver, iv->kclass));
        if (iv->kobj != 0)
          {
    !       CALL_KERNEL(ilupython_threaded_operation, ilu_RegisterLanguageSpecificObject(iv->kobj, NULL, _ilupython_LangIndex));
            iv->kobj = 0;
          }
        ilu_ExitServer(iv->kserver, iv->kclass);
    --- 79,91 ----
        CALL_KERNEL(ilupython_threaded_operation, ilu_EnterServer(iv->kserver, iv->kclass));
        if (iv->kobj != 0)
          {
    !       /* another thread may have already created a new Python object to replace this one,
    ! 	 and registered it with the kernel.  We don't want to overwrite the new Python object
    ! 	 with a NULL accidentally, so we check the pointers before calling ilu_RegisterLanguageSpecificObject */
    ! 
    !       void *inst = ilu_GetLanguageSpecificObject(iv->kobj, _ilupython_LangIndex); /* non-blocking */
    !       if ((inst == iv->pyobj) && (iv->pyobj != NULL))
    ! 	CALL_KERNEL(ilupython_threaded_operation, ilu_RegisterLanguageSpecificObject(iv->kobj, NULL, _ilupython_LangIndex));
            iv->kobj = 0;
          }
        ilu_ExitServer(iv->kserver, iv->kclass);
    ***************
    *** 98,103 ****
    --- 104,110 ----
      	v->kserver = 0;
      	v->kobj = 0;
      	v->publish_proof = 0;
    + 	v->pyobj = 0;
      #if defined(WIN32)
      	v->creatorPid = _getpid();
      #else
    

  • ilusb can segfault when called with improper arguments, due to bad command-line argument error checking. Thanks to Andreas Jung (ajung@sz-sb.de) for pointing this out.

    *** 1.14	1998/10/08 21:57:53
    --- etc/sbserver/sbservice.c	1998/11/12 16:25:00
    ***************
    *** 61,72 ****
        ilu_GetSBServiceParms(realm_name, hostname, &port);
        while (i < ac) {
          if (strcmp(av[i], "-r") == 0) {
    !       if (i++ < ac)
    ! 	strcpy(realm_name, av[i++]), i++;
            else
      	usage(av[0]);
          } else if (strcmp(av[i], "-p") == 0) {
    !       if (i++ < ac) {
      	(rawport = strtoul(av[i], ILU_NIL, 0)), i++;
      	if (rawport >= 0 && rawport <= 0xFFFF)
      	  port = rawport;
    --- 61,72 ----
        ilu_GetSBServiceParms(realm_name, hostname, &port);
        while (i < ac) {
          if (strcmp(av[i], "-r") == 0) {
    !       if (++i < ac)
    ! 	strcpy(realm_name, av[i]), i++;
            else
      	usage(av[0]);
          } else if (strcmp(av[i], "-p") == 0) {
    !       if (++i < ac) {
      	(rawport = strtoul(av[i], ILU_NIL, 0)), i++;
      	if (rawport >= 0 && rawport <= 0xFFFF)
      	  port = rawport;
    ***************
    *** 76,82 ****
            else
      	usage(av[0]);
          } else if (strcmp(av[i], "-h") == 0) {
    !       if (i++ < ac)
      	strcpy (hostname, av[i]), i++;
            else
      	usage(av[0]);
    --- 76,82 ----
            else
      	usage(av[0]);
          } else if (strcmp(av[i], "-h") == 0) {
    !       if (++i < ac)
      	strcpy (hostname, av[i]), i++;
            else
      	usage(av[0]);
    ***************
    *** 84,90 ****
            protected = ilu_TRUE;
            i++;
          } else if (strcmp(av[i], "-f") == 0) {
    !       if (i++ < ac)
      	filename = av[i++];
            else
      	usage(av[0]);
    --- 84,90 ----
            protected = ilu_TRUE;
            i++;
          } else if (strcmp(av[i], "-f") == 0) {
    !       if (++i < ac)
      	filename = av[i++];
            else
      	usage(av[0]);
    

  • End of patches