xlazom00

0001-libc-gpu-ftell-uses-LIBC_FTELL.patch

Oct 5th, 2026
28,302
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. [libc][GPU] ftell: use the LIBC_FTELL opcode instead of LIBC_FSEEK
  2.  
  3. The GPU ftell() opened the RPC port with LIBC_FSEEK and only filled data[0].
  4. The host server then called fseek(stream, data[1], data[2]) with whatever was
  5. left in the buffer from a previous message. glibc just returns EINVAL, so the
  6. bug is silent on Linux; the MSVC CRT treats an invalid 'origin' as an invalid
  7. parameter and terminates the process (0xC0000409, FAST_FAIL_INVALID_ARG).
  8. Still present in llvm-project main as of 2026-10.
  9.  
  10. --- a/libc/src/stdio/gpu/ftell.cpp
  11. +++ b/libc/src/stdio/gpu/ftell.cpp
  12. @@ -16,7 +16,7 @@
  13.  
  14. LLVM_LIBC_FUNCTION(long, ftell, (::FILE * stream)) {
  15. long ret;
  16. - rpc::Client::Port port = rpc::client.open<LIBC_FSEEK>();
  17. + rpc::Client::Port port = rpc::client.open<LIBC_FTELL>();
  18. port.send_and_recv(
  19. [=](rpc::Buffer *buffer, uint32_t) {
  20. buffer->data[0] = file::from_stream(stream);
  21.  
Advertisement