From 93fa00c19187f934cda7988a19409dd0181e2505 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 14 Nov 2025 21:08:32 +0000 Subject: [PATCH 1/4] Use `_get_platform_error()` where more appropriate --- core/os/os2/path_posix.odin | 2 +- core/os/os2/path_windows.odin | 4 ++-- core/os/os2/stat_windows.odin | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/os/os2/path_posix.odin b/core/os/os2/path_posix.odin index f22cd446b..173cb6b6d 100644 --- a/core/os/os2/path_posix.odin +++ b/core/os/os2/path_posix.odin @@ -133,7 +133,7 @@ _get_absolute_path :: proc(path: string, allocator: runtime.Allocator) -> (absol rel_cstr := clone_to_cstring(rel, temp_allocator) or_return path_ptr := posix.realpath(rel_cstr, nil) if path_ptr == nil { - return "", Platform_Error(posix.errno()) + return "", _get_platform_error() } defer posix.free(path_ptr) diff --git a/core/os/os2/path_windows.odin b/core/os/os2/path_windows.odin index e5a1545ec..1225ab2ce 100644 --- a/core/os/os2/path_windows.odin +++ b/core/os/os2/path_windows.odin @@ -305,13 +305,13 @@ _get_absolute_path :: proc(path: string, allocator: runtime.Allocator) -> (absol rel_utf16 := win32.utf8_to_utf16(rel, temp_allocator) n := win32.GetFullPathNameW(cstring16(raw_data(rel_utf16)), 0, nil, nil) if n == 0 { - return "", Platform_Error(win32.GetLastError()) + return "", _get_platform_error() } buf := make([]u16, n, temp_allocator) or_return n = win32.GetFullPathNameW(cstring16(raw_data(rel_utf16)), u32(n), cstring16(raw_data(buf)), nil) if n == 0 { - return "", Platform_Error(win32.GetLastError()) + return "", _get_platform_error() } return win32.utf16_to_utf8(buf, allocator) diff --git a/core/os/os2/stat_windows.odin b/core/os/os2/stat_windows.odin index 20a708145..651029ac3 100644 --- a/core/os/os2/stat_windows.odin +++ b/core/os/os2/stat_windows.odin @@ -287,9 +287,9 @@ _file_info_from_get_file_information_by_handle :: proc(path: string, h: win32.HA ti: win32.FILE_ATTRIBUTE_TAG_INFO if !win32.GetFileInformationByHandleEx(h, .FileAttributeTagInfo, &ti, size_of(ti)) { - err := win32.GetLastError() - if err != win32.ERROR_INVALID_PARAMETER { - return {}, Platform_Error(err) + err := _get_platform_error() + if perr, ok := is_platform_error(err); ok && perr != i32(win32.ERROR_INVALID_PARAMETER) { + return {}, err } // Indicate this is a symlink on FAT file systems ti.ReparseTag = 0 From 4267f1eb566e2d8279c82268ef79c2704bf0d850 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sat, 15 Nov 2025 18:41:30 -0500 Subject: [PATCH 2/4] Fix out of bounds access when parsing end_pos --- core/odin/parser/parser.odin | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index ce088fc64..f4beddcbb 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -99,19 +99,15 @@ end_pos :: proc(tok: tokenizer.Token) -> tokenizer.Pos { pos := tok.pos pos.offset += len(tok.text) - if tok.kind == .Comment || tok.kind == .String { - if tok.text[:2] == "/*" || tok.text[:1] == "`" { - for i := 0; i < len(tok.text); i += 1 { - c := tok.text[i] - if c == '\n' { - pos.line += 1 - pos.column = 1 - } else { - pos.column += 1 - } + if (tok.kind == .Comment && tok.text[:2] == "/*") || (tok.kind == .String && tok.text[:1] == "`") { + for i := 0; i < len(tok.text); i += 1 { + c := tok.text[i] + if c == '\n' { + pos.line += 1 + pos.column = 1 + } else { + pos.column += 1 } - } else { - pos.column += len(tok.text) } } else { pos.column += len(tok.text) From a5d9c87ac585430606c40a3f16acf4fa9805900e Mon Sep 17 00:00:00 2001 From: Ben Ryan Date: Sun, 16 Nov 2025 23:56:54 +1100 Subject: [PATCH 3/4] Add WSASendTo and WSARecvFrom --- core/sys/windows/ws2_32.odin | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/sys/windows/ws2_32.odin b/core/sys/windows/ws2_32.odin index 0d1f477c3..66054dd98 100644 --- a/core/sys/windows/ws2_32.odin +++ b/core/sys/windows/ws2_32.odin @@ -121,6 +121,18 @@ foreign ws2_32 { lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendto) + WSASendTo :: proc( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesSent: LPDWORD, + dwFlags: DWORD, + lpTo: ^SOCKADDR_STORAGE_LH, + iToLen: c_int, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecv) WSARecv :: proc( s: SOCKET, @@ -131,6 +143,18 @@ foreign ws2_32 { lpOverlapped: LPWSAOVERLAPPED, lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, ) -> c_int --- + // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsarecvfrom) + WSARecvFrom :: proc( + s: SOCKET, + lpBuffers: LPWSABUF, + dwBufferCount: DWORD, + lpNumberOfBytesRecvd: LPDWORD, + lpFlags: LPDWORD, + lpFrom: ^SOCKADDR_STORAGE_LH, + lpFromlen: ^c_int, + lpOverlapped: LPWSAOVERLAPPED, + lpCompletionRoutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE, + ) -> c_int --- // [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw) WSASocketW :: proc( af: c_int, From eb089a1c9884b39d5a2fbfd449e183661fa51e88 Mon Sep 17 00:00:00 2001 From: Laytan Date: Sun, 16 Nov 2025 15:06:30 +0100 Subject: [PATCH 4/4] skip collision panic when package names aren't unique --- src/checker.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/checker.cpp b/src/checker.cpp index 1daacd9ce..235d4def9 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -7031,9 +7031,11 @@ gb_internal void check_objc_context_provider_procedures(Checker *c) { } } -gb_internal void check_unique_package_names(Checker *c) { +gb_internal bool check_unique_package_names(Checker *c) { ERROR_BLOCK(); + bool ok = true; + StringMap pkgs = {}; // Key: package name string_map_init(&pkgs, 2*c->info.packages.count); defer (string_map_destroy(&pkgs)); @@ -7058,6 +7060,7 @@ gb_internal void check_unique_package_names(Checker *c) { continue; } + ok = false; begin_error_block(); error(curr, "Duplicate declaration of 'package %.*s'", LIT(name)); @@ -7080,6 +7083,8 @@ gb_internal void check_unique_package_names(Checker *c) { end_error_block(); } + + return ok; } gb_internal void check_add_entities_from_queues(Checker *c) { @@ -7462,7 +7467,7 @@ gb_internal void check_parsed_files(Checker *c) { debugf("Total Procedure Bodies Checked: %td\n", total_bodies_checked.load(std::memory_order_relaxed)); TIME_SECTION("check unique package names"); - check_unique_package_names(c); + bool package_names_are_unique = check_unique_package_names(c); TIME_SECTION("sanity checks"); check_merge_queues_into_arrays(c); @@ -7519,7 +7524,8 @@ gb_internal void check_parsed_files(Checker *c) { c->info.type_info_types_hash_map[index] = tt; bool exists = map_set_if_not_previously_exists(&c->info.min_dep_type_info_index_map, tt.hash, index); - if (exists) { + // Because we've already written a nice error about a duplicate package declaration, skip this panic if the package names aren't unique. + if (package_names_are_unique && exists) { for (auto const &entry : c->info.min_dep_type_info_index_map) { if (entry.key != tt.hash) { continue;