Hello Hao,

Thanks for your suggestions. Making progress; Still experimenting and
getting inconsistent results ...

Best Regards,
Olivier

On Sat, 31 Oct 2026 at 14:38, LIU Hao <[email protected]> wrote:

> 在 2026-10-29 02:54, Olivier Hainque 写道:
> > I suppose it doesn't hurt to have seh directives regardless, so I'm
> happy to simplify
> > the change accordingly.
> >
> > I'll experiment with a patch v2 and follow up as soon as I have the
> first testing results.
>
> I just took a look at the function and I think there's an issue in the
> epilogue too. The function
> currently does
>
>     push   rcx
>     push   rax
>     # end of prologue
>
>     # stack probing loop ...
>
>     # start of epilogue
>     pop    rax
>     pop    rcx
>     ret
>
> Even if we do
>
>     push   rcx
>     .seh_allocstack 8
>     push   rax
>     .seh_allocstack 8
>     .seh_endprologue
>
>     # stack probing loop ...
>
>     # start of epilogue
>     pop    rax
>     pop    rcx
>     ret
>
> The Microsoft documentation has strict rules about how an epilogue should
> be implemented:
>
> https://learn.microsoft.com/en-us/cpp/build/prolog-and-epilog?view=msvc-170#epilog-code
>
> Specifically, two questions arise here (otherwise the unwinder won't be
> able to find an epilogue):
>
> 1. What is the 'fixed-allocation-size' of this function? Is it required to
> match
>     the prologue? Is it 16? Since we aren't using a frame pointer, does
> this mean
>     that RSP can only be restored with `add rsp, 16`?
>
> 2. Is popping volatile registers allowed in an epilogue? (the doc seems to
> say 'no'.)
>
>
> As we are not allowed to clobber any registers in `__chkstk_ms`, these
> might have to be changed to
>
>     sub    rsp, 16
>     .seh_allocstack 16
>     .seh_endprologue
>     mov    [rsp], rax
>     mov    [rsp + 8], rcx
>
>     # stack probing loop ...
>
>     mov    rax, [rsp]
>     mov    rcx, [rsp + 8]
>     # start of epilogue
>     add    rsp, 16
>     ret
>
>
> Please test whether it has any impacts on your issue. Thanks.
>
>
>
>
> --
> Best regards,
> LIU Hao
>

Reply via email to