Files
hakorune/clean_test.wat
Moe Charm 80c911d3c8 🚨 Critical Issue #76: SocketBox Method Call Deadlock Investigation
## 🎯 Problem Identification Complete
- SocketBox method calls (bind, isServer, toString) cause infinite blocking
- Root cause: Method resolution pipeline deadlock before execute_socket_method
- Other Box types (ArrayBox, StringBox, MapBox) work normally
- Arc<Mutex> reference sharing confirmed working (Arc addresses match = true)

## 🔧 Debug Infrastructure Added
- Comprehensive debug logging in socket_box.rs (bind, isServer, clone, toString)
- Method call tracing in http_methods.rs
- Deadlock detection points identified at interpreter expressions.rs:462-464

## 📋 Issue #76 Created for Copilot Investigation
- Systematic root cause analysis requirements (Architecture→Parser→Runtime levels)
- Comprehensive test cases: minimal/comprehensive/comparison scenarios
- Strict prohibition of band-aid fixes - architectural analysis required
- Hypothesis: Multiple Arc<Mutex> combinations causing circular deadlock

## 🧪 Test Suite Added
- test_socket_deadlock_minimal.nyash: Minimal reproduction case
- test_socket_methods_comprehensive.nyash: All methods deadlock verification
- test_other_boxes_working.nyash: Normal Box operation confirmation
- SOCKETBOX_ISSUE_REPRODUCTION.md: Complete reproduction guide

## 📊 Impact Assessment
- Phase 9 HTTP server implementation completely blocked
- SocketBox functionality entirely non-functional
- Critical blocker for production readiness
- Requires immediate systematic investigation

🔥 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-14 20:55:33 +09:00

205 lines
3.7 KiB
Plaintext

(module
(import "env" "print" (func $print (param i32) ))
(memory (export "memory") 1)
(global $heap_ptr (mut i32) (i32.const 2048))
(func $malloc (param $size i32) (result i32)
(local $ptr i32)
(local $aligned_size i32)
;; Align size to 4-byte boundary
local.get $size
i32.const 3
i32.add
i32.const -4
i32.and
local.set $aligned_size
;; Get current heap pointer
global.get $heap_ptr
local.set $ptr
;; Advance heap pointer by aligned size
global.get $heap_ptr
local.get $aligned_size
i32.add
global.set $heap_ptr
;; Return allocated pointer
local.get $ptr
)
(func $box_alloc (param $type_id i32) (param $field_count i32) (result i32)
(local $ptr i32)
(local $total_size i32)
;; Calculate total size: header (12) + fields (field_count * 4)
local.get $field_count
i32.const 4
i32.mul
i32.const 12
i32.add
local.set $total_size
;; Allocate memory
local.get $total_size
call $malloc
local.set $ptr
;; Initialize type_id
local.get $ptr
local.get $type_id
i32.store
;; Initialize ref_count to 1
local.get $ptr
i32.const 4
i32.add
i32.const 1
i32.store
;; Initialize field_count
local.get $ptr
i32.const 8
i32.add
local.get $field_count
i32.store
;; Return box pointer
local.get $ptr
)
(func $alloc_stringbox (result i32)
(local $ptr i32)
;; Allocate memory for box
i32.const 20
call $malloc
local.set $ptr
;; Initialize type_id
local.get $ptr
i32.const 4097
i32.store
;; Initialize ref_count to 1
local.get $ptr
i32.const 4
i32.add
i32.const 1
i32.store
;; Initialize field_count
local.get $ptr
i32.const 8
i32.add
i32.const 2
i32.store
;; Return box pointer
local.get $ptr
)
(func $alloc_integerbox (result i32)
(local $ptr i32)
;; Allocate memory for box
i32.const 16
call $malloc
local.set $ptr
;; Initialize type_id
local.get $ptr
i32.const 4098
i32.store
;; Initialize ref_count to 1
local.get $ptr
i32.const 4
i32.add
i32.const 1
i32.store
;; Initialize field_count
local.get $ptr
i32.const 8
i32.add
i32.const 1
i32.store
;; Return box pointer
local.get $ptr
)
(func $alloc_boolbox (result i32)
(local $ptr i32)
;; Allocate memory for box
i32.const 16
call $malloc
local.set $ptr
;; Initialize type_id
local.get $ptr
i32.const 4099
i32.store
;; Initialize ref_count to 1
local.get $ptr
i32.const 4
i32.add
i32.const 1
i32.store
;; Initialize field_count
local.get $ptr
i32.const 8
i32.add
i32.const 1
i32.store
;; Return box pointer
local.get $ptr
)
(func $alloc_databox (result i32)
(local $ptr i32)
;; Allocate memory for box
i32.const 16
call $malloc
local.set $ptr
;; Initialize type_id
local.get $ptr
i32.const 4101
i32.store
;; Initialize ref_count to 1
local.get $ptr
i32.const 4
i32.add
i32.const 1
i32.store
;; Initialize field_count
local.get $ptr
i32.const 8
i32.add
i32.const 1
i32.store
;; Return box pointer
local.get $ptr
)
(func $main (local $0 i32) (local $1 i32) (local $2 i32)
nop
i32.const 10
local.set $0
i32.const 20
local.set $1
local.get $0
local.get $1
i32.add
local.set $2
local.get $2
return
)
(export "main" (func $main))
)