SEGV compiling this class

minyard@acm.org minyard@acm.org
Thu Jun 21 14:33:00 GMT 2001


I checked with GDB, it is exactly the same thing as you reported.  I
also have a set of classes that reproduce this on x86 and PowerPC.
I'll include them.  I also build a stock compiler (without my GC and
threads package) and it had the same problem.

I looked the the except.c code and I think I know what the problem is.
At least I see something kind of obvious :-).  If you look at some of
the previous loops in duplicate_eh_regions, they look like:

  for (i = 1; i <= ifun_last_region_number; ++i)
    {
      cur = ifun->eh->region_array[i];
      if (!cur || cur->region_number != i)
	continue;
      n_array[i] = duplicate_eh_region_1 (cur, map);
    }

But the one where the exception happens is:

      for (i = 1; i <= ifun_last_region_number; ++i)
	if (n_array[i]->outer == NULL)
	  n_array[i]->outer = cur;

In the exeption-causing loop, there is no check for n_array[i] being
null, even though it seems that it is quite possible this is the case
from the previous loop.  However, I don't even pretend to pretend I
know what this code is doing.  Anyway, I have a small patch that seems
to fix the problem:

--- except.c.old	Thu Jun 21 16:30:31 2001
+++ except.c	Thu Jun 21 16:30:00 2001
@@ -1448,7 +1448,7 @@
 	cur->inner = root;
 
       for (i = 1; i <= ifun_last_region_number; ++i)
-	if (n_array[i]->outer == NULL)
+	if (n_array[i] && (n_array[i]->outer == NULL))
 	  n_array[i]->outer = cur;
     }
   else


-Corey

>minyard@acm.org writes:
>
>> it works fine on PowerPC.
>
>I couldn't reproduce the bug with the trunk and 3.0 on RHL7.1/x86, but
>it crashed on Linux/Alpha with -O, though it seems to be for different
>reasons.
>
>./A


public class SymbolInvalidError extends Exception
{
    public final static String Revision = "$Revision: 1.1 $";

    public SymbolInvalidError(String info) {
        super(info);
    }
}

public class SymbolTableValueEntry
{
    public static final String Revision = "$Revision: 1.10 $";

    /* The entry in the name tree for this value. */
    private String name;


    public byte infoByte;
    public Object infoObject;

    public String getName() throws SymbolInvalidError
    {
	return this.name;
    }
}

import java.util.Vector;
import SymbolTableValueEntry;
import SymbolInvalidError;

class tester
{
    private Vector ignorePacks = new Vector();
    private byte ignorePackCurrInfoByte = 1;

    private synchronized final boolean inIgnoredPackages(String name)
    {
	int    i;
	int    length = ignorePacks.size();
	String val;

	for (i=0; i<length; i++) {
	    val = (String) ignorePacks.elementAt(i);
	    if (name.indexOf(val) != -1) {
		return true;
	    }
	}

	return false;
    }

    private final void testBranchTrace(SymbolTableValueEntry v)
    {
	try {
	    String name = v.getName();

	    if (((name.charAt(0) == '_') && (! name.startsWith("__Q")))
		|| name.startsWith("pthread")
		|| name.startsWith("egc")
		|| inIgnoredPackages(name))
	    {
		v.infoByte = (byte) -ignorePackCurrInfoByte;
	    } else {
		v.infoByte = ignorePackCurrInfoByte;
	    }
	} catch (SymbolInvalidError e) {
	    v.infoByte = ignorePackCurrInfoByte;
	}
    }

}



More information about the Java mailing list