Skip to content

Conversation

@dschuff
Copy link
Member

@dschuff dschuff commented Dec 10, 2024

The test was failing under ASan because no null byte was being
read from the file, so the strlen inside printf was running
off the buffer. It just happened to work on non-ASan because
wasm memory is initialized to zero.

The test was failing under ASan because no null byte was being
read from the file, so the strlen inside printf was running
off the buffer. It just happened to work on non-ASan because
wasm memory is initialized to zero.
@dschuff dschuff enabled auto-merge (squash) December 10, 2024 20:57
@dschuff dschuff requested a review from sbc100 December 10, 2024 20:58
int src_fd = open("link_source", O_CREAT | O_WRONLY, 0777);
printf("source_fd: %d, errno: %d %s\n", src_fd, errno, strerror(errno));
write(src_fd, "abc", 3);
write(src_fd, "abc\0", 4);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems a little odd to write null byte to a text file.. but I guess its not important here.

{
int target_fd = open("link_source", O_RDONLY);
printf("target_fd: %d, errno: %d %s\n", target_fd, errno, strerror(errno));
char buf[10];
Copy link
Collaborator

Choose a reason for hiding this comment

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

An alternative here I suppose would be intialize buf on the stack with char buf[10] = { '\0' };

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I could go either way on that, do you have a preference?

@dschuff dschuff disabled auto-merge December 11, 2024 04:34
@dschuff dschuff merged commit 1171ada into emscripten-core:main Dec 11, 2024
25 of 28 checks passed
@hoodmane
Copy link
Collaborator

Thanks!

hedwigz pushed a commit to hedwigz/emscripten that referenced this pull request Dec 18, 2024
The test was failing under ASan because no null byte was being
read from the file, so the strlen inside printf was running
off the buffer. It just happened to work on non-ASan because
wasm memory is initialized to zero.
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