Skip to content

Conversation

@monkeyWie
Copy link
Contributor

@monkeyWie monkeyWie commented Dec 26, 2025

Summary

Stack overflow occurs in goja when attempting to convert an object containing a circular reference to a primitive value (via toPrimitive, toString, toNumeric, etc.).

Minimal Reproduction

package main

import (
	"fmt"
	"github.com/dop251/goja"
)

func main() {
	vm := goja.New()
	
	code := `
		var T = [1, 2, 3];
		T[42] = T;       // Create circular reference
		var x = T % 2;   // Modulo operation triggers toPrimitive -> toString
	`
	
	_, err := vm.RunString(code)
	if err != nil {
		fmt.Printf("ERROR: %v\n", err)
	}
}

Environment

  • Go version: go1.25.4 darwin/arm64
  • OS: macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant