Repository navigation
fix(server): fix the three engine errors the sanitizer job found - #3373
Conversation
🤖 Internal: Discord sync markerAuto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
- Each class that declares `FactoryType` also declares `FactoryRoot` - `makeFactory` stores and `find` calls a `Factory::Method<I>`, the root's type - Remove the unused `makeFactory` overload with a custom factory function - aptest case for an interface derived from the factory root Part of #3369
`TestMain` keeps the path in a named `Text` until `session.run` returns. Part of #3369
bbef557 to
2237e3a
Compare
dsapandora
left a comment
There was a problem hiding this comment.
Thank you @asclearuc. Storing and calling every factory method at the root's type, with the static_cast refusing an interface whose FactoryArgs differ, removes the mismatch at its source, and the two memory fixes free what was allocated, the way it was allocated. On this PR's sanitizer run all 72 reports are ~range_error freed in libc++abi at __cxa_end_catch; none of the three groups fixed here is left.
Approve
nit, no changed line to sit on: the new aptest case passes on the old code in a normal build, so the sanitizer job is the only thing that catches a regression here. Making it required in the follow-up is what keeps these fixed.
Summary
The sanitizer CI job from #3350 reported 5 groups of errors (#3369). This PR fixes the three that are in our code:
function-type-mismatch, every engine process).makeFactory<Object, Interface>stored a constructor that returnsPtr<Interface>and takesFactoryArgs&&.Factory::find<T>called it as a function that returnsPtr<T>and takesFactoryArgsby value.Interfaceis often a derived interface (IPipeTask<L>,IPython*Base,IBase*) andTits root (ITask,IServiceEndpoint, …), so both the return type and the parameter differed.FactoryTypenow also declaresusing FactoryRoot = <itself>;(7 classes).Factory::Method<I>is the one type of a stored method: it returnsPtr<I::FactoryRoot>and takesI::FactoryRoot::FactoryArgs&&.makeFactorystoresstatic_cast<Method<Interface>>(objectConstructor<Object, Root, Interface::FactoryArgs>), so an interface whoseFactoryArgsdiffer from its root's does not compile.find<T>calls the method asMethod<T>and converts the root pointer toTwithcastMovePtr.makeFactoryoverload that took a custom factory function is removed: none of the 82 registrations uses it.engtestandnodetestgave Catch2 a pointer into a freed string (ASanheap-use-after-freeat start).TestMainpushedText(cmdline[0]), a temporary, into the argument list. The path now lives in a namedTextuntilsession.runreturns.new[]memory withdelete(ASanalloc-dealloc-mismatch).constant_mbrfrees each chunk withdelete[]on theuint8_tarray it allocated.The other two groups in #3369 are one problem outside our code: the
libc++abi.so.1that CI ships frees a caught exception's message withfree, while ASan'soperator newallocated it. The follow-up PR handles it in the report script and makes the job required.Type
fix
Testing
static_assertthat both meet at the root's method type. Without the fix the case still passes in a normal build: it runs the call UBSan reported (a constructor stored for a derived interface, called as the root's), so on a regression the sanitizer job is what fails.--cmake-config=Sanitize --nodownload, with the sanitizer options of the CI job../builder testpasses: run under the LinuxSanitizebuild only; CI runs the three platforms.The WSL row comes from a full run of this diff without its last two edits (a comment line in
Factory.hand thestatic_assert). After those edits, aptest was rebuilt and its two Factory cases passed with no sanitizer report.The libc++abi group shows only with the toolchain of the CI runner, so this PR's own sanitizer run (label
ci:sanitize) should show that one group and nothing else.Checklist
Linked Issue
Part of #3369
Summary by CodeRabbit