This patch fixes two problems I had with jikes 1.11, described briefly
in the ChangeLog. I'm not subscribed to jikes-dev and haven't checked
my changes against jikes cvs, but I hope this is helpful anyway.
The first has to do with +M and -d. When the list of files is created
to make dependencies in control.cpp it includes both .java files and
.class files. The .class files have a null semantic data member
(FileSymbol::semantic) and this causes a segfault when using
FileSymbol::OutputDirectory(). The semantic data is meant to be used
in parsing the java file and storing various things so fixing this
problem in this way might be going about it in just the simplest way
rather than the way which makes the most sense.
The second problem turned up after fixing the first and has nothing to
do with the first problem. In option.cpp, classpath was being
assigned to a part of arguments in one place and in another place
could otherwise be assigned to a copy of the environment jikes path or
classpath. In the destructor for Option delete[] was called on
classpath and failed in libc free() when it had been assigned to
arguments and not environment variables.
Brian
--
Brian Jones <[EMAIL PROTECTED]>
diff -uNr jikes.orig/ChangeLog jikes/ChangeLog
--- jikes.orig/ChangeLog Thu Jan 6 03:24:30 2000
+++ jikes/ChangeLog Sat Mar 18 15:04:54 2000
@@ -1,3 +1,13 @@
+2000-03-18 C. Brian Jones <[EMAIL PROTECTED]>
+ * option.cpp:
+ Create a copy classpath from arguments so it can be deleted
+ similarly to when classpath comes from environment variables.
+ * depend.cpp:
+ When creating dependency files, some of the file symbols represent
+ class files and semantic is null although it is used for
+ determining the output directory. Here in OutputMake semantic
+ is now properly set to avoid later accessing a null pointer.
+
2000-01-06 Vadim Zaliva <[EMAIL PROTECTED]>
* +1.0 command line option and all related code and
diff -uNr jikes.orig/src/depend.cpp jikes/src/depend.cpp
--- jikes.orig/src/depend.cpp Thu Jan 6 19:25:53 2000
+++ jikes/src/depend.cpp Sat Mar 18 14:17:58 2000
@@ -299,11 +299,15 @@
char *buf;
int length;
+ // .class files in the file_symbol list have null semantic data
+ // and calling FileSymbol::OutputDirectory can fail with segfault
+ if (! file_symbol -> semantic)
+ file_symbol -> semantic = new Semantic (*control, file_symbol);
+
if (control -> option.directory == NULL)
{
name = file_symbol -> FileName();
- length = file_symbol -> FileNameLength() - (file_symbol -> IsJava() ? FileSymbol::java_suffix_length
- : FileSymbol::class_suffix_length);
+ length = file_symbol -> FileNameLength() - (file_symbol -> IsJava() ? FileSymbol::java_suffix_length : FileSymbol::class_suffix_length);
}
else
{
diff -uNr jikes.orig/src/option.cpp jikes/src/option.cpp
--- jikes.orig/src/option.cpp Thu Jan 6 03:24:30 2000
+++ jikes/src/option.cpp Sat Mar 18 14:33:08 2000
@@ -231,6 +231,11 @@
for (int k = 0; k < strlen(classpath); k++)
classpath[k] = Code::ToASCII(classpath[k]);
#endif
+ /* Create a copy of the classpath string we can later properly delete */
+ char * buf;
+ buf = new char[strlen(classpath)];
+ strcpy(buf, classpath);
+ classpath = buf;
}
else if (strcmp(arguments.argv[i], "-depend") == 0 || strcmp(arguments.argv[i], "-Xdepend") == 0)
depend = true;