Skip to content

Conversation

tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Mar 30, 2023

This series changes the mark stack and various macros to use SSIze_t instead of I32 for marks.

It also fixes several places where perl uses an I32 as an index into the stack, or an index into a list on the stack, or as a count of items returned on the stack.

It doesn't attempt to fix all I32 problems, but I do have a little list I'll work through of potential problems to check out.

Fixes #20917

@iabyn
Copy link
Contributor

iabyn commented Mar 30, 2023 via email

@tonycoz
Copy link
Contributor Author

tonycoz commented Apr 3, 2023

I don't intend to apply it until 5.39, I expect the changes could cause some noise downstream (mostly C conversion warnings if anyone enables them).

I'll rebase on top of the refcounted stack changes once they're applied.

@tonycoz tonycoz added the defer-next-dev This PR should not be merged yet, but await the next development cycle label Apr 3, 2023
@iabyn
Copy link
Contributor

iabyn commented Apr 3, 2023 via email

@tonycoz tonycoz marked this pull request as draft July 4, 2023 00:24
@tonycoz
Copy link
Contributor Author

tonycoz commented Jul 4, 2023

Made this draft to ensure it isn't merged until refcounted stack it merged.

@demerphq
Copy link
Collaborator

demerphq commented Jul 4, 2023

@iabyn I think you should merge your refcounted stack changes asap.

@tonycoz tonycoz removed the defer-next-dev This PR should not be merged yet, but await the next development cycle label Jul 10, 2023
@tonycoz tonycoz force-pushed the 20917-mark-of-an-appropriate-size branch from c0f8f7a to 4352e5e Compare July 27, 2023 05:16
@tonycoz tonycoz force-pushed the 20917-mark-of-an-appropriate-size branch from 4352e5e to a13ffe9 Compare August 21, 2023 05:08
@tonycoz tonycoz force-pushed the 20917-mark-of-an-appropriate-size branch from a13ffe9 to fd8c051 Compare August 22, 2023 23:57
@tonycoz tonycoz marked this pull request as ready for review August 23, 2023 01:21
Done by updating the definitions for AX and items to SSize_t

The bootcheck macros will require a bit more work, and need
a separate test.
I'm not entirely happy with this, since we're changing the return
type and the types of the items and ax values passed via va_args.

But an excuse: the return and the fetching of ax and items via
va_args both happen after we've validated the handshake key, which
would prevent the va_arg() fetches and the return.

But but: this is fine for va_args, but purely the call to the
function with the different return type is technically undefined
behaviour.

I'm not sure it's worth trying to workaround that, since it will
require code duplication for a rare case, that I expect to just
work on the platforms involved (64-bit platforms).
The tests here move/set a lot of memory, and this makes them slow.

If we want to debug a particular test, running them all wastes
a lot of time, so allow particular tests to be run.
OP_LIST is optimised away in many cases, the hard part was
creating the test.

This ended up being fixed by one of Dave's rc_stack patches, but leave
the test in.
Not really related to the stack, but this came up when searching
for I32 mis-use.

This didn't crash, instead the loop exited early.
I can't write a test for this, I'd expect it to use at least 96GB
to test.
This calls repeatcpy() which took an I32 for the size of the object
to copy, change this to SSize_t, and update the list code in
pp_repeat to only test if the new allocation would fail.
No real way to test this.

i looks suspicious too, but it can't go above 15.
Since pp_mapwhile mortalcopy()s many SVs I don't have enough memory
to test this usefully, so no tests.
I do think it's unlikely apply() would be called with >2G filenames
or handles, but it's a limit.

The test is slow, very slow.
index into the parameter list.
eval_sv() had two problems, it saved the starting stack position
in an I32, so a call with a deep stack would save a negative or
otherwise invalid depth, and the return value was an I32, so
if the eval returned a large list the return count would overflow.
call_sv() used I32 for a saved mark and the return value.

The XS::APItest call_sv() wrapper used an I32 index to reposition
the argument list supplied to call_sv().

I haven't created additional tests for call_argv(), call_pv() nor
call_method(), these simply pass the return value on, I don't think
it worth the extra tests.
@tonycoz tonycoz force-pushed the 20917-mark-of-an-appropriate-size branch from fd8c051 to ac78ddd Compare September 25, 2023 00:05
@tonycoz
Copy link
Contributor Author

tonycoz commented Sep 25, 2023

Applied manually

@tonycoz tonycoz closed this Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the mark stack (and dMARK etc) are I32 even on 64-bit platforms

3 participants