Skip to content

Commit f690fea

Browse files
authored
fix: base address dependant storage (#225)
* fix: memory overused with high base address The pattern language evaluator uses storage whose size is calculated using the value offset. When a base address has been set that is not zero, the offset will then increase and so will the storage allocated. To correct this we detect when patterns are using the main section to calculate the storage size based on offset that has the base address removed. * rewrite code for clarity. * All that was written before is incorrect. The problem was that setVariable was using the offset of the instance inside the input file (value->getOffset()) to calculate the heap storage size instead of using the offset of the instance inside the pattern that occupies the heap (pattern->getOffset()).
1 parent 4088d48 commit f690fea

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/source/pl/core/evaluator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ namespace pl::core {
710710
auto &storage = getStorage();
711711
if (value->getSection() != ptrn::Pattern::InstantiationSectionId) {
712712
if (heapSection || patternLocalSection) {
713-
storage.resize((value->getOffset() & 0xFFFF'FFFF) + value->getSize());
713+
storage.resize((pattern->getOffset() & 0xFFFF'FFFF) + value->getSize());
714714
this->readData(value->getOffset(), storage.data(), value->getSize(), value->getSection());
715715
} else if (storage.size() < pattern->getOffset() + pattern->getSize()) {
716716
storage.resize(pattern->getOffset() + pattern->getSize());

0 commit comments

Comments
 (0)