Commit 4d5b560
committed
Phase 116: Critical undefined behavior fixes
Fixed 3 CRITICAL and 4 HIGH priority undefined behavior issues:
CRITICAL FIXES:
1. ltable.cpp:1243 - Added bounds check for bit mask shift (prevent UB when n >= 32)
2. ltable.cpp:730 - Split shift validation into separate checks (prevent shift UB)
3. ltable.cpp:1250 - Added wrap-around assertion for hash table doubling
HIGH PRIORITY FIXES:
4. ltable.cpp:707-708 - Added bounds validation for table array reallocation pointer arithmetic
5. lvm_string.cpp:73-74 - Fixed GC safety in string concatenation (recapture stack pointer after GC)
6. lstack.h:118-125 - Eliminated char* round-trip in stack save/restore (direct pointer arithmetic)
7. ltable.cpp:105-136 - Added overflow checks and alignment assertions for NodeArray memory layout
ADDITIONAL CHANGES:
- Added <cstdint> include for uintptr_t type
- All assertions verify safety invariants at runtime
TESTING:
- All 30+ test files pass: "final OK !!!"
- Performance: 4.36s average (4.14s-4.59s range)
- Target: ≤4.33s (within normal variance)
Status: Phase 116 complete, 7/11 critical+high issues fixed1 parent cec2445 commit 4d5b560
3 files changed
+30
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
114 | 122 | | |
115 | 123 | | |
116 | 124 | | |
| |||
131 | 139 | | |
132 | 140 | | |
133 | 141 | | |
| 142 | + | |
| 143 | + | |
134 | 144 | | |
135 | 145 | | |
136 | 146 | | |
| |||
704 | 714 | | |
705 | 715 | | |
706 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
707 | 720 | | |
708 | 721 | | |
709 | 722 | | |
| |||
727 | 740 | | |
728 | 741 | | |
729 | 742 | | |
730 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
731 | 746 | | |
732 | 747 | | |
733 | 748 | | |
| |||
1240 | 1255 | | |
1241 | 1256 | | |
1242 | 1257 | | |
| 1258 | + | |
1243 | 1259 | | |
1244 | 1260 | | |
1245 | 1261 | | |
1246 | 1262 | | |
1247 | 1263 | | |
1248 | 1264 | | |
1249 | 1265 | | |
| 1266 | + | |
1250 | 1267 | | |
| 1268 | + | |
1251 | 1269 | | |
1252 | 1270 | | |
1253 | 1271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
| 67 | + | |
| 68 | + | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| |||
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| 78 | + | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
| |||
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| 94 | + | |
88 | 95 | | |
89 | 96 | | |
90 | 97 | | |
| |||
0 commit comments