Skip to content

Commit f93cb97

Browse files
authored
Merge pull request #30 from s-ludwig/fix_null_pointer_access
Fix null pointer access when iterating over empty arrays
2 parents 14a9547 + d788f49 commit f93cb97

7 files changed

Lines changed: 210 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,46 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest, windows-latest]
1919
dc: [dmd-latest, ldc-latest, ldc-1.15.0]
20-
arch: [x86, x86_64]
20+
arch: [x86_64]
21+
include:
22+
- {os: windows-latest, dc: ldc-latest, arch: x86}
2123

2224
runs-on: ${{ matrix.os }}
2325
steps:
24-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v4
2527

2628
- name: Install D compiler
27-
uses: dlang-community/setup-dlang@v1
29+
uses: dlang-community/setup-dlang@v2
2830
with:
2931
compiler: ${{ matrix.dc }}
3032

3133
- name: Run tests
32-
env:
33-
CONFIG: ${{matrix.config}}
34-
ARCH: ${{matrix.arch}}
3534
shell: bash
36-
run: dub test :engine
35+
run: dub test :engine -a ${{matrix.arch}}
3736
testsuite:
3837
name: Test262
3938
strategy:
4039
fail-fast: false
4140
matrix:
4241
os: [ubuntu-latest]
43-
dc: [dmd-latest]
44-
arch: [x86_64]
42+
dc: [ldc-latest]
4543

4644
runs-on: ${{ matrix.os }}
4745
steps:
48-
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v4
4947

5048
- name: Install D compiler
51-
uses: dlang-community/setup-dlang@v1
49+
uses: dlang-community/setup-dlang@v2
5250
with:
53-
compiler: ${{ matrix.dc }}
51+
compiler: ${{matrix.dc}}
5452

5553
- name: Run tests
56-
env:
57-
CONFIG: ${{matrix.config}}
58-
ARCH: ${{matrix.arch}}
5954
shell: bash
6055
run: ./run-test262.sh
56+
57+
- name: Upload log
58+
uses: actions/upload-artifact@v3
59+
if: always()
60+
with:
61+
name: runtest262 log
62+
path: dmdscript-test262.log

engine/source/dmdscript/RandAA.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ public:
510510
// handle it.
511511
GC.free(cast(void*)this._keys);
512512
GC.free(cast(void*)this.flags);
513-
GC.free(cast(void*)this.vals);
514513

515514
static if(storeHash)
516515
{

engine/source/dmdscript/iterator.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ struct Iterator
7070
ostart = o;
7171
this.o = o;
7272
this.callcontext = cc;
73-
keys = o.proptable.table.keys.sort!((a, b) => a.compare(cc, b) < 0).release;
73+
if (o.proptable.table)
74+
keys = o.proptable.table.keys.sort!((a, b) => a.compare(cc, b) < 0).release;
7475
keyindex = 0;
7576
}
7677

run-test262.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ if ! [ -d test262-harness-py ] ; then
1717
git clone https://github.com/test262-utils/test262-harness-py.git
1818
cd test262-harness-py
1919
git checkout 0f2acdd882c84cff43b9d60df7574a1901e2cdcd
20-
cd ..
2120
echo "Applying patch to adjust the runner for the latest version of the test suite..."
22-
sed '/self\.suite\.GetInclude("cth\.js")/d' -i test262-harness-py/src/test262.py
21+
patch --merge -f -u -i ../test262-patches/test262-test262.py.patch -p1
22+
patch --merge -f -u -i ../test262-patches/test262-_monkeyYaml.py.patch -p1
23+
patch --merge -f -u -i ../test262-patches/test262-parseTestRecord.py.patch -p1
24+
cd ..
2325
fi
2426

2527
echo "Running the test suite..."
2628
cd test262-harness-py
27-
python2 src/test262.py --summary --non_strict_only --command ../timed-dmdscript.sh --tests=../test262 | tee ../dmdscript-test262.log | grep '=== .* failed in .* ==='
29+
python3 src/test262.py --summary --non_strict_only --command ../timed-dmdscript.sh --tests=../test262 | tee ../dmdscript-test262.log | grep -a '=== .* failed in .* ==='
2830
cd ..
2931

30-
EXPECTED_TO_PASS=5223
31-
PASSED=$(grep ' - Passed [0-9]* tests' dmdscript-test262.log | sed -n 's/.*Passed \([0-9]*\) tests.*/\1/;P')
32+
EXPECTED_TO_PASS=5238
33+
PASSED=$(grep -a ' - Passed [0-9]* tests' dmdscript-test262.log | sed -n 's/.*Passed \([0-9]*\) tests.*/\1/;P')
3234

3335
if [ "$PASSED" -gt "$EXPECTED_TO_PASS" ]; then
3436
echo "The number of passed tests has increased ($PASSED vs. $EXPECTED_TO_PASS)."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git "a/src/_monkeyYaml.py" "b/src/_monkeyYaml.py"
2+
index bc6d128..a8327e0 100644
3+
--- "a/src/_monkeyYaml.py"
4+
+++ "b/src/_monkeyYaml.py"
5+
@@ -75,7 +75,7 @@ def myMultilineList(lines, value):
6+
leading = myLeadingSpaces(line)
7+
if myIsAllSpaces(line):
8+
pass
9+
- elif leading < indent:
10+
+ elif indent != None and leading < indent:
11+
lines.insert(0, line)
12+
break;
13+
else:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git "a/src/parseTestRecord.py" "b/src/parseTestRecord.py"
2+
index 22d5664..5be3a5f 100644
3+
--- "a/src/parseTestRecord.py"
4+
+++ "b/src/parseTestRecord.py"
5+
@@ -78,7 +78,7 @@ def yamlAttrParser(testRecord, attrs, name):
6+
parsed = yamlLoad(body)
7+
8+
if (parsed is None):
9+
- print "Failed to parse yaml in name %s"%(name)
10+
+ print ("Failed to parse yaml in name %s"%(name))
11+
return
12+
13+
for key in parsed:
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
diff --git "a/src/test262.py" "b/src/test262.py"
2+
index c92e5bf..a6722d8 100644
3+
--- "a/src/test262.py"
4+
+++ "b/src/test262.py"
5+
@@ -42,8 +42,8 @@ def ReportError(s):
6+
7+
8+
if not os.path.exists(EXCLUDED_FILENAME):
9+
- print "Cannot generate (JSON) test262 tests without a file," + \
10+
- " %s, showing which tests have been disabled!" % EXCLUDED_FILENAME
11+
+ print ("Cannot generate (JSON) test262 tests without a file," + \
12+
+ " %s, showing which tests have been disabled!" % EXCLUDED_FILENAME)
13+
sys.exit(1)
14+
EXCLUDE_LIST = xml.dom.minidom.parse(EXCLUDED_FILENAME)
15+
EXCLUDE_REASON = EXCLUDE_LIST.getElementsByTagName("reason")
16+
@@ -111,10 +111,10 @@ class TempFile(object):
17+
text = self.text)
18+
19+
def Write(self, str):
20+
- os.write(self.fd, str)
21+
+ os.write(self.fd, str.encode())
22+
23+
def Read(self):
24+
- f = file(self.name)
25+
+ f = open(self.name, "r", encoding="latin-1")
26+
result = f.read()
27+
f.close()
28+
return result
29+
@@ -128,7 +128,7 @@ class TempFile(object):
30+
try:
31+
self.Close()
32+
os.unlink(self.name)
33+
- except OSError, e:
34+
+ except OSError as e:
35+
logging.error("Error disposing temp file: %s", str(e))
36+
37+
38+
@@ -145,20 +145,20 @@ class TestResult(object):
39+
mode = self.case.GetMode()
40+
if self.HasUnexpectedOutcome():
41+
if self.case.IsNegative():
42+
- print "=== %s was expected to fail in %s, but didn't ===" % (name, mode)
43+
- print "--- expected error: %s ---\n" % self.case.GetNegativeType()
44+
+ print ("=== %s was expected to fail in %s, but didn't ===" % (name, mode))
45+
+ print ("--- expected error: %s ---\n" % self.case.GetNegativeType())
46+
else:
47+
if long_format:
48+
- print "=== %s failed in %s ===" % (name, mode)
49+
+ print ("=== %s failed in %s ===" % (name, mode))
50+
else:
51+
- print "%s in %s: " % (name, mode)
52+
+ print ("%s in %s: " % (name, mode))
53+
self.WriteOutput(sys.stdout)
54+
if long_format:
55+
- print "==="
56+
+ print ("===")
57+
elif self.case.IsNegative():
58+
- print "%s failed in %s as expected" % (name, mode)
59+
+ print ("%s failed in %s as expected" % (name, mode))
60+
else:
61+
- print "%s passed in %s" % (name, mode)
62+
+ print ("%s passed in %s" % (name, mode))
63+
64+
def WriteOutput(self, target):
65+
out = self.stdout.strip()
66+
@@ -302,7 +302,6 @@ class TestCase(object):
67+
return self.test
68+
69+
source = self.suite.GetInclude("sta.js") + \
70+
- self.suite.GetInclude("cth.js") + \
71+
self.suite.GetInclude("assert.js")
72+
73+
if self.IsAsyncTest():
74+
@@ -373,7 +372,7 @@ class TestCase(object):
75+
return result
76+
77+
def Print(self):
78+
- print self.GetSource()
79+
+ print (self.GetSource())
80+
81+
def validate(self):
82+
flags = self.testRecord.get("flags")
83+
@@ -488,7 +487,7 @@ class TestSuite(object):
84+
basename = path.basename(full_path)[:-3]
85+
name = rel_path.split(path.sep)[:-1] + [basename]
86+
if EXCLUDE_LIST.count(basename) >= 1:
87+
- print 'Excluded: ' + basename
88+
+ print ('Excluded: ' + basename)
89+
else:
90+
if not self.non_strict_only:
91+
strict_case = TestCase(self, name, full_path, True)
92+
@@ -511,9 +510,9 @@ class TestSuite(object):
93+
def write(s):
94+
if logfile:
95+
self.logf.write(s + "\n")
96+
- print s
97+
+ print (s)
98+
99+
- print
100+
+ print ()
101+
write("=== Summary ===");
102+
count = progress.count
103+
succeeded = progress.succeeded
104+
@@ -527,12 +526,12 @@ class TestSuite(object):
105+
positive = [c for c in progress.failed_tests if not c.case.IsNegative()]
106+
negative = [c for c in progress.failed_tests if c.case.IsNegative()]
107+
if len(positive) > 0:
108+
- print
109+
+ print ()
110+
write("Failed Tests")
111+
for result in positive:
112+
write(" %s in %s" % (result.case.GetName(), result.case.GetMode()))
113+
if len(negative) > 0:
114+
- print
115+
+ print ()
116+
write("Expected to fail but passed ---")
117+
for result in negative:
118+
write(" %s in %s" % (result.case.GetName(), result.case.GetMode()))
119+
@@ -541,7 +540,7 @@ class TestSuite(object):
120+
for result in progress.failed_tests:
121+
if logfile:
122+
self.WriteLog(result)
123+
- print
124+
+ print ()
125+
result.ReportOutcome(False)
126+
127+
def Run(self, command_template, tests, print_summary, full_summary, logname, junitfile):
128+
@@ -585,9 +584,9 @@ class TestSuite(object):
129+
if full_summary:
130+
self.PrintFailureOutput(progress, logname)
131+
else:
132+
- print
133+
- print "Use --full-summary to see output from failed tests"
134+
- print
135+
+ print ()
136+
+ print ("Use --full-summary to see output from failed tests")
137+
+ print ()
138+
return progress.failed
139+
140+
def WriteLog(self, result):
141+
@@ -619,7 +618,7 @@ class TestSuite(object):
142+
includes = case.GetIncludeList()
143+
includes_dict.update(includes)
144+
145+
- print includes_dict
146+
+ print (includes_dict)
147+
148+
149+
def Main():
150+
@@ -659,6 +658,6 @@ if __name__ == '__main__':
151+
try:
152+
code = Main()
153+
sys.exit(code)
154+
- except Test262Error, e:
155+
- print "Error: %s" % e.message
156+
+ except Test262Error as e:
157+
+ print ("Error: %s" % e.message)
158+
sys.exit(1)

0 commit comments

Comments
 (0)