Conversation
afc0330 to
e1854ce
Compare
bnoordhuis
left a comment
There was a problem hiding this comment.
I don't have time to look at this in detail today but apropos the linux and macos test failures:
# exit code 6
# Output from process `ipc_send_zero`:
# /Users/runner/work/libuv/libuv/src/unix/stream.c:701:15: runtime error: applying zero offset to null pointer
# SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/libuv/libuv/src/unix/stream.c:701:15 in
# exit_cb
# Assertion failed in /Users/runner/work/libuv/libuv/test/test-ipc.c on line 95: `term_signal == 0` (6 == 0)
Does that mean ubsan wasn't running before? The failure looks legitimate; uv__write_req_update() should check buf->base != NULL.
It was running, but in recovery mode, which means the default ubsan runtime, with the default settings, was only printing the problems, but not crashing the program. The test-runner hides output unless the test fails, so that is why I believe you didn't see these failures before.
Yep, fixed locally, just didn't push the commit yet. I am investigating one more macOS ubsan failure I see running on my machine, but not on CI: |
7186d90 to
ec938b9
Compare
|
Is it possible to get macos-arm64 github workflow working? |
Are those even available when you're not on a paid plan? |
dd67964 to
065d56d
Compare
|
Nevermind, I see that the closest to my machine (macOS 14 arm64) we have CI available for free is macOS 13 intel. Adding it does expose a different test failure I had seen locally, but it's not ubsan related, so I will split that off for another PR. And about the ubsan failure on osx_select_many_fds, I failed to realize before that this test is even skipped on CI due to lack of /dev/tty. |
77d2342 to
d05df52
Compare
bnoordhuis
left a comment
There was a problem hiding this comment.
I have to admit, while I appreciate the work you've done, a number of these changes don't look Obviously Correct(TM) to me.
As in: they quite possibly are, but not obviously so, and that makes me hesitant to sign off on it. Maybe you can elaborate on why you made specific changes, and why you took specific approaches instead of others?
Thanks for the input. I gave it another round of edits, but otherwise please point to specific commits if you want more explanation on them. |
|
Hello, just a friendly ping on this MR. |
|
Hello, another ping. Would you prefer we expedite this by splitting off less controversial commits to another MR? If you think that's possible, please let me know which commits. |
|
I have honestly completely forgotten where we left off on this, after a very busy month. If there are small chunks you think would be easier to merge separately, by all means we can do those first. |
|
Bump? Can you remind me where we are with this if nothing is left to change, rebase it, or split into smaller chunks so that each can be merged quickly? |
|
I think this just got stalled on review from libuv side. That's why I asked if there was a list of changes you would consider more quickly, so that we could reduce the diff. Now I realize this needs to be rebased. I may have time to do that this weekend. |
|
Thanks. I reviewed and identified only 1 commit that seemed it should be split out. As well as some minor nits that would be appreciate to clean up so that this can be merged soon. |
MSVC does not actually support ubsan. There is a long-standing ticket requesting this: https://developercommunity.visualstudio.com/t/add-support-for-ubsan/840750 There are no known compilers that currently accept the `/fsanitize=undefined` spelling. clang-cl accepts `-fsanitize...`, same as regular clang. Also passes no-sanitizer-recover so that tests actually fail.
Don't use CONTAINING_RECORD macro from WinSDK, as it doesn't use the right trick which avoids member access on null pointer. Fixes: ``` src/win/req-inl.h:86:10: runtime error: member access within null pointer of type 'uv_req_t' (aka 'struct uv_req_s') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior D:/a/libuv/libuv/src/win/req-inl.h:86:10 ```
Don't call functions through different function type. Fixes: ``` src/win/udp.c:537:5: runtime error: call to function req_cb through pointer to incorrect function type 'void (*)(struct uv_udp_send_s *, int)' test\test-ref.c:66: note: req_cb defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/udp.c:537:5 in ```
When accessing HANDLEs within the stdio buffer, use memcpy / memset in order to respect alignment.
Fixes:
```
src/win/process-stdio.c:197:5: runtime error: store to misaligned address 0x0230ee72d107 for type 'HANDLE' (aka 'void *'), which requires 8 byte alignment
0x0230ee72d107: note: pointer points here
00 00 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd fd fd fd fd
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/process-stdio.c:197:5 in
```
Reworks buffer alignment handling to respect requirements.
Fixes:
```
src/win/getaddrinfo.c:157:23: runtime error: member access within misaligned address 0x0290e4c6a17c for type 'struct addrinfo', which requires 8 byte alignment
0x0290e4c6a17c: note: pointer points here
00 00 00 00 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/getaddrinfo.c:157:23 in
```
Changes "random" representation from pointer to number. Fixes: ``` src/win/pipe.c:234:11: runtime error: applying non-zero offset to non-null pointer 0xffffffffffffffff produced null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/win/pipe.c:234:11 in ```
Avoids performing pointer arithmetic on null pointer. Fixes: ``` src/unix/stream.c:701:15: runtime error: applying zero offset to null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/runner/work/libuv/libuv/src/unix/stream.c:701:15 in ```
|
All done. As you can see, we will be failing Windows UBSAN CI for now, as the fix for that failure in |
vtjnash
left a comment
There was a problem hiding this comment.
Some style nits. I will apply those directly as this otherwise looks ready to merge to me
MSVC does not actually support ubsan. There is a long-standing ticket requesting this:
https://developercommunity.visualstudio.com/t/add-support-for-ubsan/840750
There are no known compilers that currently accept the
/fsanitize=undefinedspelling. clang-cl accepts-fsanitize..., same as regular clang.