google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.26k stars 204 forks source link

Detecting json loops #431

Closed marco6 closed 1 year ago

marco6 commented 1 year ago

Json encoding is not checking for loops in Starlark values, so code like this:

a = {}
a["a"] = a
json.encode(a)

crash the application with a stack overflow like:

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020260370 stack=[0xc020260000, 0xc040260000]
fatal error: stack overflow
<...>

This PR should fix the behavior.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.