Commit Graph

19079 Commits

Author SHA1 Message Date
user.name
6ccde7f80b bugfix: core/encoding/json leaks the key and value of a malformed object
parse_object_body allocates an object key, then may fail in parse_colon or
parse_value before that key is ever inserted into the object. Its cleanup defer
only walks `obj`, so a key that never got there is unreachable to it. The caller
cannot free it either -- a failed parse returns a nil Value -- so it leaks.

The same applies to the parsed element on the duplicate-key path, and to both on
the out-of-memory path.

JSON5 makes this reachable from ordinary malformed input, because an unquoted
ident is a legal key and anything other than a colon after it fails. Plain JSON
leaks it too, via a quoted key.

before, measured with a tracking allocator over 8 inputs x 2 specs:

	LEAK JSON5  colon fails after unquoted key   1 alloc / 7 bytes
	LEAK JSON   colon fails after quoted key     1 alloc / 2 bytes
	LEAK JSON5  colon fails after quoted key     1 alloc / 2 bytes
	LEAK JSON   value fails after key            1 alloc / 2 bytes
	LEAK JSON5  value fails after key            1 alloc / 2 bytes
	LEAK JSON   nested value fails               2 alloc / 4 bytes
	LEAK JSON5  nested value fails               2 alloc / 4 bytes
	LEAK JSON   deep nesting fails               3 alloc / 6 bytes
	LEAK JSON5  deep nesting fails               3 alloc / 6 bytes
	LEAK JSON   array element fails              1 alloc / 2 bytes
	LEAK JSON5  array element fails              1 alloc / 2 bytes
	total leaked allocations: 17

after, same probe:

	total leaked allocations: 0

The leak scales with nesting depth -- one orphaned key per enclosing object -- so
a service parsing untrusted JSON leaks a little on every malformed request.

The fix marks the key and the element as owned by the loop iteration until they
are stored, and frees them otherwise. The duplicate-key path loses its explicit
delete, which the same mechanism now covers.

Found via odinfmt, which reported a 7-byte leak in a downstream test that parses
`{ broken not json` to check that invalid input is rejected.

Regression test added to tests/core/encoding/json: it reports
`17 leaks and 0 bad frees` without this change and passes with it. The existing
11 tests pass unchanged under -define:ODIN_TEST_FAIL_ON_BAD_MEMORY=true.
2026-08-31 11:39:42 -07:00
Jeroen van Rijn
de2b46961a Merge pull request #7468 from mac119/fix-7421-tagless-switch-duplicate-cases
checker: Do not deduplicate cases in tagless switches
2026-08-31 04:06:08 -07:00
Jeroen van Rijn
54b680a167 Merge pull request #7480 from FourteenBrush/patch-8
`core:net`: use explicitly passed allocators
2026-08-29 13:49:04 -07:00
Jeroen van Rijn
efc7db8619 Merge pull request #7481 from thetarnav/fix-parsing-same-line-comments
Improve `core:odin/parser` parsing field docs and comments
2026-08-29 13:47:10 -07:00
FourteenBrush
a635f0ef91 net.split_url: fix length on query values 2026-08-29 22:39:15 +02:00
FourteenBrush
57181d5c27 Avoid allocations in net.split_url 2026-08-29 21:54:26 +02:00
thetarnav
db2f88cff9 Improve parsing field docs and comments (fixes #5353) 2026-08-29 19:22:18 +02:00
FourteenBrush
af6bcc13d6 net.parse_record: use explicitly passed allocator 2026-08-29 18:56:08 +02:00
FourteenBrush
7198bf5d80 net.split_url: use explicitly passed allocator 2026-08-29 18:27:07 +02:00
gingerBill
db0cd79633 Use thread_safe_file 2026-08-27 15:26:29 +01:00
gingerBill
938257d425 Add -strict-style-packages 2026-08-27 15:20:02 +01:00
gingerBill
1598ac2489 Merge pull request #7466 from laytan/os-add-device-to-file-info
[core:os] add `device` to `File_Info`
2026-08-27 11:05:42 +01:00
leo119
24cb1abf29 checker: Do not deduplicate cases in tagless switches
Tagless switch cases are ordered predicates, so distinct constant conditions may fold to the same Boolean value. Restrict duplicate-case tracking to explicitly tagged switches and add positive and negative regression coverage for issue #7421.
2026-08-27 14:53:54 +08:00
Laytan Laats
3fb6d8965b [core:os] add device to File_Info 2026-08-26 20:44:01 +02:00
Laytan
897c99a9a3 [core:debug/trace] remove os, fmt, slice, and strconv imports (#7408)
* [core:debug/trace] remove `os`, `fmt`, `slice`, and `strconv` imports

* [core:debug/trace]: print memory nicely

A bit of a modified, minimal core:fmt `%m` (to not need `core:strconv`)
2026-08-26 20:19:38 +02:00
Jeroen van Rijn
9909676141 Merge pull request #7462 from MoonlightChase/fix-grapheme-width
This Fixes #5939 , where many characters like flags are reported with…
2026-08-26 06:14:30 -07:00
MoonlightChase
556bdb0056 This Fixes #5939 , where many characters like flags are reported with width 1 even though their width is 2. Country glags need additional special case also since RI letters are EAW neutral and not Wide.
i was working on this when i stumbled on this bug, so i did bunch of different characters to see which ones cause issue, hence test has many different options. I could make it either simpler or split it, as needed.
2026-08-26 13:31:43 +02:00
Jeroen van Rijn
4da9d4a01e Add tests/abi/build to .gitignore 2026-08-26 13:02:56 +02:00
Jeroen van Rijn
e510297fe2 Merge pull request #7463 from Kelimion/fix-fmt
Fix justified printing of `0` producing all spaces.
2026-08-26 03:31:17 -07:00
Jeroen van Rijn
6a83f08c8b Fix justified printing of 0 producing all spaces. 2026-08-26 12:11:38 +02:00
gingerBill
fee21e1aad Merge pull request #7456 from pes18fan/libc-shim-typo-fix
Fix typo in sched.odin in vendor:libc-shim
2026-08-26 10:41:10 +01:00
gingerBill
2cd0e1fbce Merge pull request #7457 from kalsprite/const_array_broadcast
broadcast a constant into every array level
2026-08-26 09:15:21 +01:00
gingerBill
34643f30d9 Merge branch 'master' into const_array_broadcast 2026-08-26 08:45:51 +01:00
gingerBill
cef4fb01a4 Merge pull request #7424 from samuelgozi/foundation-cocoa-ios
core:sys/darwin/Foundation: Skip Cocoa import on iOS
2026-08-26 08:43:35 +01:00
gingerBill
d06ac2fe64 Merge pull request #7428 from mocompute/check-7336
add regression test for #7336
2026-08-26 08:43:06 +01:00
gingerBill
dcb66ab09d Merge branch 'master' into const_array_broadcast 2026-08-26 08:42:51 +01:00
gingerBill
7bd6d16d76 Merge pull request #7438 from kalsprite/asm_doc_category
Give asm templates a documentation category instead of a blank header and a null `%s`
2026-08-26 08:41:20 +01:00
gingerBill
85b9dcb4b8 Merge pull request #7461 from kalsprite/fmt_left_align_space_pad
fill left-justified field with spaces
2026-08-26 08:41:00 +01:00
gingerBill
dc8b9584ed Merge pull request #7458 from kalsprite/swizzle_multi_assign
Fix a swizzle target in a multi-assignment reading an already-written source
2026-08-26 08:40:42 +01:00
gingerBill
a934751be1 Merge pull request #7435 from kalsprite/asm_group_empty_params
Delete dead code that crashed the checker on an asm template group with no parameters
2026-08-26 08:40:20 +01:00
gingerBill
4c0e5dfdc8 Merge pull request #7460 from kalsprite/const_truncation_sweep
convert constants before narrowing to i64 in the remaining checker sites
2026-08-26 08:39:48 +01:00
gingerBill
f1a348616a Merge pull request #7459 from kalsprite/i128_endian_specific
add missing i128le, i128be to endian switch
2026-08-26 08:38:18 +01:00
kalsprite
7d7d9a01ee fill left-justified field with spaces 2026-08-25 23:55:55 -07:00
kalsprite
7e9ffac5b0 const truncation sweep 2026-08-25 23:27:06 -07:00
kalsprite
c3bc5b69ac Merge branch 'master' into asm_doc_category 2026-08-25 23:08:48 -07:00
kalsprite
3d4fcd3612 merge master 2026-08-25 23:07:38 -07:00
kalsprite
deeddc7b33 add missing endian 128 types 2026-08-25 23:03:11 -07:00
kalsprite
915fc97b5f add missing int 128le 2026-08-25 22:46:30 -07:00
kalsprite
c1aeb47ce5 swizzle target multi-assignment 2026-08-25 22:22:33 -07:00
kalsprite
ae549bf34b broadcast a constant into every array level 2026-08-25 21:47:02 -07:00
pes18fan
21651fe392 Fix typo in sched.odin in vendor:libc-shim 2026-08-26 10:20:31 +05:45
mo
2d1253e3e6 add regression test for #7336
Closes #7336.
Fixed by #7327.
2026-08-26 15:08:01 +12:00
Jeroen van Rijn
251d8eb0b1 Merge pull request #7455 from mocompute/test-runner-microarch
Remove microarch:native from 3 Windows tests and tweak Win test runner
2026-08-25 15:35:35 -07:00
mo
9ddc2c5ea1 remove -microarch:native from 3 tests due to suspected GH issue
These tests often fail on GitHub runners which use AMD EPYC 9V74
VMs. We suspect LLVM generates AVX512 instructions, which are valid
for the hardware, but not available on the GH VM.
2026-08-26 10:13:54 +12:00
mo
750aecb6de win test runner: ignore informational exceptions
and accept BREAK and CLOSE as synonyms for CTRL_C
2026-08-26 10:12:13 +12:00
Jeroen van Rijn
651a4ea016 Merge pull request #7454 from Skarsh/fix-simple-typo
Fix simple typo in process.odin
2026-08-25 13:20:11 -07:00
Thomas Skarshaug
9e1e7d60c9 Fix simple typo in process.odin 2026-08-25 21:49:11 +02:00
gingerBill
96b1b45f69 Merge branch 'master' of https://github.com/odin-lang/Odin 2026-08-25 19:30:50 +01:00
gingerBill
f7f3d3f198 asm: reenable riscv64 2026-08-25 19:30:38 +01:00
gingerBill
073c733dbd Merge pull request #7432 from kalsprite/asm_immediate_constant
Reject a non-constant argument to an  template's  immediate
2026-08-25 16:20:38 +01:00