Open krasin opened 4 years ago
@sebcaux thank you for the awesome tool, btw!
I have played with it a little longer, and it's clear that the same pin gets assigned to two different packages. The one of the packages gets deleted and (surprisingly) the Package destructor also deletes pins (including the shared one), and then this pins gets accessed from another Package.
DatasheetPackage::~DatasheetPackage()
{
for (int i=0; i<pins.size(); i++) {
delete pins[i];
}
}
One way to resolve that is to consider that a Package does not own its pins (so, it does not delete them). Instead, push its ownership to Datasheet. This way, sharing pins across different packages won't be problem.
Another option is to copy pins. Basically, instead of QList<DatasheetPin *> pins;
make it QList<DatasheetPin> pins;
.
It's also possible that there's a better fix, but I am not familiar enough with the code base to have a good intuition of what fix would be consistent with the rest of the uConfig logic.
Any suggestions are welcome. I would be more than happy to come up with a (tested) pull request, but would like to have a suggestion about what's the preferred course of actions here.
uconfig crashes with heap-use-after-free error when running on LM393 datasheet from https://lcsc.com/product-detail/Analog-Comparators_ON-Semicon_LM393DR2G_ON-Semicon-ON-LM393DR2G_C7955.html
To reproduce:
Note: the same error occurs if built without Address Sanitizer, but it obviously misses the nice report.
The code around the issue is:
What happens is that package (including its pins) is deleted on one iteration and then on the next iteration, a deleted pin is used again. I have not yet fully understood the problem, but I hope this report gives enough clues.