Commit Graph

130 Commits

Author SHA1 Message Date
Jeong, YunWon
f777416870 initial sandbox (#7035)
* Add host_env feature for sandbox isolation

Introduce a `host_env` feature flag that gates all host environment
access (filesystem, network, signals, processes). When disabled,
the VM operates in sandbox mode:

- _io module always available; FileIO gated by host_env
- SandboxStdio provides lightweight stdin/stdout/stderr via Rust std::io
- BytesIO/StringIO/BufferedIO/TextIOWrapper work without host_env
- open() returns UnsupportedOperation in sandbox
- stdlib modules (os, socket, signal, etc.) gated by host_env
- CI checks both host_env ON and OFF builds

* Auto-format: ruff check --select I --fix

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-08 13:58:30 +00:00
Jeong, YunWon
5dabad6702 reason inside #[allow] (#7049) 2026-02-08 13:11:50 +00:00
Jeong, YunWon
07fc6ee3c7 no_std clippy (#7043) 2026-02-08 16:49:18 +09:00
Jeong, YunWon
2e62cac72b Implement more warnings 2026-02-05 23:50:08 +09:00
Jeong, YunWon
cdb7b0d5ca align overlapped to CPython 3.14.2 (#7005) 2026-02-05 23:38:35 +09:00
Jeong, YunWon
e56705455a Remove _use_vfork 2026-02-04 11:15:58 +09:00
Jeong, YunWon
674d7dbb3a rework SchedParam 2026-02-03 22:10:31 +09:00
Jeong, YunWon
cb2be65a8b fix timeout 2026-02-03 22:10:31 +09:00
Jeong, YunWon
477e20a7a9 Support #[cfg] in with (#6975) 2026-02-03 18:55:59 +09:00
Jeong, YunWon
cdadde55ef Update faulthandler to match CPython 3.14.2
- Rewrite faulthandler with live frame walking via
  Frame.previous AtomicPtr chain and thread-local
  CURRENT_FRAME (AtomicPtr) instead of frame snapshots
- Add signal-safe traceback dumping (dump_live_frames,
  dump_frame_from_raw) walking the Frame.previous chain
- Add safe_truncate/dump_ascii for UTF-8 safe string
  truncation in signal handlers
- Refactor write_thread_id to accept thread_id parameter
- Add SA_RESTART for user signal registration, SA_NODEFER
  only when chaining
- Save/restore errno in faulthandler_user_signal
- Add signal re-entrancy guard in trigger_signals to
  prevent recursive handler invocation
- Add thread frame tracking (push/pop/cleanup/reinit)
  with force_unlock fallback for post-fork recovery
- Remove expectedFailure markers for now-passing tests
2026-02-03 13:41:58 +09:00
Jeong, YunWon
ab6114d5a2 Merge pull request #6942 from youknowone/os-fix
posix.link, termios.error, warn() error, closefd=False for std in/out
2026-02-02 08:11:46 +09:00
Jeong, YunWon
d1b55f584e Merge pull request #6902 from youknowone/asyncio
Update asyncio to 3.14.2
2026-02-02 08:04:52 +09:00
Jeong, YunWon
d8e582ef6e _locale.localeconv (#6941) 2026-02-02 02:02:12 +09:00
Jeong, YunWon
188d438e00 Use new_os_subtype_error for termios error construction
- Replace manual exception creation with new_os_subtype_error in termios
- Remove redundant .to_owned() calls in os.link() error messages
2026-02-02 01:54:58 +09:00
Jeong, YunWon
5e732c5e2a Fix wasip2 build (#6935) 2026-02-02 01:26:17 +09:00
Jeong, YunWon
fe40dd37c0 impl more _asyncio 2026-02-02 00:43:07 +09:00
Jeong, YunWon
5e4c3b07fb gc is vm/stdlib (#6929) 2026-02-01 13:21:24 +09:00
Jeong, YunWon
714d1ce58b gc module internal structure and API (#6910)
* gc module internal structure and API

Add gc_state module with GcState, GcGeneration, GcDebugFlags, GcStats.
Replace gc module stubs with working API backed by gc_state.
Add gc_callbacks and gc_garbage to Context.
Add is_gc_tracked, gc_finalized, gc_get_referents to PyObject.
Collection is stubbed (returns 0) — actual algorithm to follow.

* fix dict/weakref/generators

* unmark test_asyncio

* apply review
2026-02-01 08:51:39 +09:00
Shahar Naveh
743d6b83d3 Split stack_effect into pushed & popped (#6893) 2026-01-31 16:58:14 +09:00
Jeong, YunWon
050faa312a Fix _overlapped segfault and missing _winapi constants
- Fix from_windows_err using new_exception_empty on OSError subclasses
  (ConnectionRefusedError, ConnectionAbortedError), which caused segfault
  in release builds due to debug_assert on type size mismatch
- Move ConnectPipe from instance method to module-level function
- Add Destructor for Overlapped to cancel pending I/O on object cleanup
- Add NMPWAIT_NOWAIT, NMPWAIT_USE_DEFAULT_WAIT, NMPWAIT_WAIT_FOREVER
  constants to _winapi
2026-01-31 06:39:32 +09:00
Jeong YunWon
d8fa1b4366 _asyncio rust impl 2026-01-29 16:48:33 +09:00
Jeong YunWon
aaa86584e5 Add _asyncio 2026-01-29 16:48:33 +09:00
Jeong YunWon
2e0b76556a Add more socket consts 2026-01-29 16:48:33 +09:00
Jeong, YunWon
e363b14e81 fix ssl MSG_PEEK (#6892) 2026-01-29 16:48:02 +09:00
Jeong, YunWon
0cc43e192c Implement Windows overlapped I/O for asyncio support
Add comprehensive Windows async I/O support to the overlapped module:

Winsock Extensions:
- Initialize AcceptEx, ConnectEx, DisconnectEx, TransmitFile via WSAIoctl
- Proper cleanup with all four extension locks checked

Overlapped Methods:
- ReadFile, ReadFileInto: Async file reading
- WriteFile: Async file writing
- WSARecv, WSARecvInto: Async socket receive
- WSASend: Async socket send
- WSARecvFrom, WSARecvFromInto: Async UDP receive with address
- WSASendTo: Async UDP send to address
- AcceptEx: Async socket accept
- ConnectEx: Async socket connect
- DisconnectEx: Async socket disconnect
- TransmitFile: Async file transmission over socket
- ConnectNamedPipe, ConnectPipe: Named pipe support

Module Functions:
- CreateIoCompletionPort: IOCP creation/association
- GetQueuedCompletionStatus: Dequeue completion packets
- PostQueuedCompletionStatus: Post completion packets
- RegisterWaitWithQueue: Register wait with completion port callback
- UnregisterWait, UnregisterWaitEx: Unregister waits with proper cleanup
- BindLocal: Bind socket to local address
- CreateEvent, SetEvent, ResetEvent: Event object management
- FormatMessage: Windows error message formatting

Safety & Correctness:
- Validate buffer contiguity before async operations
- Validate size parameters to prevent buffer overflow
- Use Arc for RegisterWaitWithQueue callback data to prevent UAF
  (callback may run after UnregisterWait returns per Windows API docs)
2026-01-28 16:56:47 +09:00
fanninpm
4c1c704bb1 Add ExpatError and error to pyexpat (#6889)
* Stub out xml.parsers.expat.ExpatError

* Alias `ExpatError` to `error`
2026-01-28 10:19:00 +09:00
Jeong, YunWon
edca32a194 Fix ssl shutdown (#6871)
* Fix ssl shutdown

* Fix thread
2026-01-27 02:50:15 +09:00
Jeong, YunWon
7eceb145b1 more optimization (#6860) 2026-01-25 10:18:47 +02:00
Jeong YunWon
c0bdb9a3e5 align psuedo ops to 3.14.2 2026-01-24 16:09:40 +09:00
Jeong YunWon
771650a012 align HAVE_ARGUMENT 2026-01-24 16:09:40 +09:00
Jeong, YunWon
efce325cbf Fix asyncio related compiler/library issues (#6837)
* Fix socket bytes support

* fix unwind_fblock

* fix posix.sendfile

* fix ssl_write

* Fix SSL ZeroReturn

* fix context

* fix generator

* Enable unittest test_async_case again
2026-01-23 19:59:29 +09:00
Jeong, YunWon
125ade5f55 fix clippy 1.93.0 (#6836)
* fix clippy 1.93.0

* Auto-format: cargo fmt --all

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-01-23 02:18:39 +09:00
Jeong, YunWon
40a43f3210 instruction improvements (#6829)
New Features

Direct small-integer loading (0–255) and locals-loading for faster execution
Async-generator wrapping and improved generator resume behavior
Performance

Faster integer loads and streamlined jump/loop handling for better runtime performance
Bug Fixes

More robust StopIteration handling and stricter init return checks
Corrected iterator cleanup for async and sync loops
Improvements

Aligns loop and jump semantics with CPython 3.14 patterns
2026-01-22 17:25:56 +09:00
Jeong YunWon
20376451eb Implement Py_mod_create slot support in multi-phase init 2026-01-22 11:21:42 +09:00
Jeong YunWon
bc02b2318c module_exec 2026-01-21 22:39:40 +09:00
Jeong YunWon
32d2406fa8 module_def 2026-01-21 22:39:40 +09:00
Jeong YunWon
fee1a4b097 multiphase 2026-01-21 22:39:39 +09:00
Jeong, YunWon
2df879c5ee Fix Drop to prevent TLS data loss (#6825)
Remove pending_tls_output.clear() from Drop implementation.

SSLSocket._real_close() in Python doesn't call shutdown() before
closing - it just sets _sslobj = None. This means pending TLS data
in the output buffer may not have been flushed to the socket yet.
Clearing this buffer in Drop causes data loss, resulting in empty
HTTP responses (test_socketserver failure on Windows).

The explicit clearing is also unnecessary since all struct fields
are automatically freed when the struct is dropped.
2026-01-21 17:29:22 +09:00
Jeong, YunWon
274e8b4b6b Remove JUMP_IF_NOT_EXC_MATCH, SET_EXC_INFO (#6820) 2026-01-21 01:23:43 +09:00
Jeong, YunWon
e0cceaf31c Remove ReturnConst/Break/Continue ops (#6816)
* Remove ReturnConst

* Remove break/continue ops
2026-01-21 00:03:43 +09:00
Jeong, YunWon
f0c3e7d51f Remove SUBSCRIPT, JUMP_IF_{TRUE,FALSE}_OR_POP (#6810)
* Align ForIter behavior (incomplete)

* Romove JUMP_IF_{TRUE,FALSE}_OR_POP, subscript

* Remove LoadAssetionError

* Update snapshot for ForIter behavior change
2026-01-20 16:21:23 +09:00
Jeong, YunWon
ef2c0a6d9d More FromArgs message (#6806) 2026-01-20 10:37:27 +09:00
Jeong, YunWon
6a064aad3b Drop for PySSLSocket (#6791) 2026-01-19 10:01:11 +09:00
Jeong, YunWon
130bb82a43 LoadClosure as pseudo op (#6789) 2026-01-19 02:45:00 +09:00
Jiseok CHOI
050db4725f sqlite3: fix Connection.cursor() factory argument handling (#6783)
Fix test_is_instance in CursorFactoryTests by properly handling the
factory argument in Connection.cursor() method. Now the factory can
be passed as both positional and keyword argument, and returns the
correct subclass type instead of always returning PyRef<Cursor>.

- Use FromArgs derive macro with CursorArgs struct for argument parsing
- Return PyObjectRef instead of PyRef<Cursor> to allow subclasses
- Use fast_issubclass to validate returned cursor is a Cursor subclass
- Properly differentiate between 'no argument' and 'None passed'
2026-01-18 23:37:47 +09:00
Jeong, YunWon
6f266651c0 better ssl write handling (#6763)
* ssl_write

* Fix thread count timing
2026-01-18 21:10:35 +09:00
Jeong, YunWon
f5b44f505a Fix Exception.__init__ 2026-01-17 19:21:11 +09:00
Jeong, YunWon
746e71af87 reject SemLock reduce (#6738) 2026-01-16 10:18:31 +09:00
Lee Dogeon
3a702ac772 Improve json.loads performance (#6704)
* Parse JSON in Rust

* Reuse key when decoding JSON

* Unmark resolved test

* Parse null/true/false directly in call_scan_once

Parse JSON constants (null, true, false) directly in Rust within
call_scan_once() instead of falling back to Python scan_once.
This reduces Python-Rust boundary crossings for array/object values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Parse numbers directly in call_scan_once

Parse JSON numbers starting with digits (0-9) directly in Rust within
call_scan_once() by reusing the existing parse_number() method.
This reduces Python-Rust boundary crossings for array/object values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Parse NaN/Infinity/-Infinity in call_scan_once

Parse special JSON constants (NaN, Infinity, -Infinity) and negative
numbers directly in Rust within call_scan_once(). This handles:
- 'N' -> NaN via parse_constant callback
- 'I' -> Infinity via parse_constant callback
- '-' -> -Infinity or negative numbers via parse_constant/parse_number

This reduces Python-Rust boundary crossings for array/object values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Correct wrong index access

* Leave more flame span

* Refactor json scanstring with byte index

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 19:53:46 +09:00
Shahar Naveh
e3890f9b4a Bytecode pseudo opcodes (#6715) 2026-01-15 02:52:25 +09:00