Skip to content

Conversation

@tmc
Copy link
Contributor

@tmc tmc commented Oct 28, 2025

What issue is this addressing?

#356

What type of issue is this addressing?

bug

What this PR does | solves

Fixes improper use of outer loop variable when handling strings.

Additionally, adds a tool to generate various stack tests.

@tmc tmc force-pushed the fix-darwin-int-string-mixing branch from b5d5bfe to 72a33da Compare October 28, 2025 12:11
Copy link
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

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

There seem a lot of TODOs. Is this intended?

@tmc
Copy link
Contributor Author

tmc commented Oct 28, 2025

I'll open a separate PR with the test generation code.

I'm finding a host of darwin abi incompatibilities and opted to start generating the tests.

tmc added 2 commits October 28, 2025 06:17
Add test case that verifies multiple string arguments passed on the stack
each receive their correct distinct values, rather than all receiving the
same duplicated value. This test catches the bug fixed in the previous
commit where v.String() was incorrectly used instead of val.String().
Use the correct loop variable 'val' instead of 'v' when converting string
arguments to C strings. This ensures each string argument is properly
converted rather than repeatedly using the same outer scope variable.
@tmc tmc force-pushed the fix-darwin-int-string-mixing branch from 72a33da to 27c814f Compare October 28, 2025 13:17
Copy link
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

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

LGTM

@TotallyGamerJet Please take a look

@tmc
Copy link
Contributor Author

tmc commented Oct 28, 2025

note: This change is included in #353

@hajimehoshi
Copy link
Member

note: This change is included in #353

Then I'll make #353 a draft until this PR is merged.

@hajimehoshi hajimehoshi requested a review from Copilot October 28, 2025 17:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where multiple string arguments passed on the stack were receiving duplicate values instead of their correct individual values. The issue was caused by using the outer loop variable instead of the inner loop variable when converting strings to C strings.

  • Fixed incorrect variable reference in string conversion loop (line 290 of func.go)
  • Added C test function test_8i32_3strings to verify multiple strings on stack work correctly
  • Added corresponding Go test case to validate the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
func.go Fixed bug where v.String() was used instead of val.String(), causing all stack strings to get the same value
testdata/abitest/abi_test.c Added C function to test multiple strings passed on stack with 8 int32 parameters
func_test.go Added test case that calls the new C function with 3 different strings to verify they maintain distinct values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tmc added 2 commits October 28, 2025 10:46
Match the project's C formatting conventions:
- Single-line function signatures
- 4-space indentation
- Consistent pointer spacing

Addresses review feedback about line formatting.
Copy link
Collaborator

@TotallyGamerJet TotallyGamerJet left a comment

Choose a reason for hiding this comment

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

LGTM

@hajimehoshi hajimehoshi merged commit 1bb4460 into ebitengine:main Oct 29, 2025
41 checks passed
hajimehoshi pushed a commit that referenced this pull request Oct 29, 2025
Add test case that verifies multiple string arguments passed on the stack
each receive their correct distinct values, rather than all receiving the
same duplicated value. This test catches the bug fixed in the previous
commit where v.String() was incorrectly used instead of val.String().

Closes #356
tmc added a commit to tmc/purego that referenced this pull request Oct 29, 2025
Add test case that verifies multiple string arguments passed on the stack
each receive their correct distinct values, rather than all receiving the
same duplicated value. This test catches the bug fixed in the previous
commit where v.String() was incorrectly used instead of val.String().

Closes ebitengine#356
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.

3 participants