Skip to content

Fix bug 4822 - gex_Segment_Attach() does not validate the size argument#7

Merged
PHHargrove merged 2 commits into
BerkeleyLab:developfrom
PHHargrove:attach-arg-checks
May 14, 2026
Merged

Fix bug 4822 - gex_Segment_Attach() does not validate the size argument#7
PHHargrove merged 2 commits into
BerkeleyLab:developfrom
PHHargrove:attach-arg-checks

Conversation

@PHHargrove
Copy link
Copy Markdown
Collaborator

@PHHargrove PHHargrove commented May 14, 2026

Summary:

Adds argument validation to ensure the documented constraints on the size argument to gex_Segment_Attach() are satisfied.

Status:

The "too large" case tested via testcore2 with smp-conduit, 2 procs, in a Docker container with /dev/shm of size 64MB.
The "non-zero" and "multiple of GASNET_PAGESIZE" cases were not directly tested.
A make run-tests-par was used to confirm lack of regressions.

@PHHargrove PHHargrove requested a review from bonachea May 14, 2026 05:09
@PHHargrove PHHargrove force-pushed the attach-arg-checks branch from 2635e2c to 6931f75 Compare May 14, 2026 05:11
Copy link
Copy Markdown
Member

@bonachea bonachea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix!

One minor cosmetic request, otherwise LGTM based on source inspection

Comment thread gasnet_internal.c Outdated
@PHHargrove PHHargrove requested a review from bonachea May 14, 2026 18:01
Copy link
Copy Markdown
Member

@bonachea bonachea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This commit adds checks on the `size` argument to
`gex_Segment_Attach()` which were inadvertently lost early in the
GASNet-1 to GASNet-EX transition.  Specifically, this enforces all
three constraints in the following:

> [size] must be a non-zero multiple of GASNET_PAGESIZE, not larger
> than gasnet_getMaxLocalSegmentSize()

For all three error cases (zero, not page-aligned, or too large)
the behavior is to return `GASNET_ERR_BAD_ARG` with the belief
that the client might be able to recover.  Additionally, while the
documentation does not (currently?) require it, the output location
`*segment_p` is set to `GEX_SEGMENT_INVALID` to reduce the scope of
cascading errors in any clients which do not check the return value.

One example failure message (assuming verbose errors are enabled):
```
*** WARNING (proc 0): GASNet gex_Segment_Attach returning an error code: GASNET_ERR_BAD_ARG (Invalid function parameter passed)
  at /[redacted]/gasnet_internal.c:623
  reason: size is too large, exceeds current value of gasnet_getMaxLocalSegmentSize()
```
@PHHargrove PHHargrove force-pushed the attach-arg-checks branch from ec94b67 to c50e053 Compare May 14, 2026 20:14
@PHHargrove PHHargrove merged commit 7291e64 into BerkeleyLab:develop May 14, 2026
38 checks passed
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.

2 participants