Skip to content

Transforming unsupported types into a set leads to crashing #206

Description

@xiaxinmeng

Transforming invalid types into a set with set() leads to crashing of gpython. For example:

x = set('abcde')

or


class A: pass
set(A())

Output on go/wasm(https://gpython.org/?wasm):

Gpython 3.4.0 running in your browser with go/wasm
>>> class A: pass
>>> set(A())
panic: interface conversion: py.Object is *py.Type, not py.Tuple
goroutine 5 [running]:
github.com/go-python/gpython/py.SetNew(0xc051170, 0xc05ec10, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x109b0006)
    /home/ncw/go/src/github.com/go-python/gpython/py/set.go:63 +0x14
github.com/go-python/gpython/py.(*Type).M__call__(0xc051170, 0xc05ec10, 0x1, 0x1, 0x0, 0x9d401, 0xc061b00, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/py/type.go:380 +0x4
github.com/go-python/gpython/py.Call(0x9d4a0, 0xc051170, 0xc05ec10, 0x1, 0x1, 0x0, 0x9d4a0, 0xc061b00, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/py/internal.go:169 +0x5
github.com/go-python/gpython/vm.callInternal(0x9d4a0, 0xc051170, 0xc05ec10, 0x1, 0x1, 0x0, 0xc0a4420, 0x9d4a0, 0xc061b00, 0x0, ...)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1606 +0xd
github.com/go-python/gpython/vm.(*Vm).Call(0xc0744d0, 0x180000000001, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1689 +0x4e
github.com/go-python/gpython/vm.do_CALL_FUNCTION(0xc0744d0, 0x1, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1428 +0x2
github.com/go-python/gpython/vm.RunFrame(0xc0a4420, 0x0, 0xc07bd18, 0x0, 0x0)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1785 +0x3f
github.com/go-python/gpython/vm.EvalCodeEx(0xc04c500, 0xc062db0, 0xc062db0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2162 +0xa3
github.com/go-python/gpython/vm.Run(0xc062db0, 0xc062db0, 0xc04c500, 0x0, 0x0, 0x0, 0x0, 0x1, 0x9d240, 0xc04c500)
    /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2182 +0x2
github.com/go-python/gpython/repl.(*REPL).Run(0xc09a6c0, 0xc01e4d8, 0x8)
    /home/ncw/go/src/github.com/go-python/gpython/repl/repl.go:99 +0x20
main.main.func1(0xc01e4c0, 0x2, 0x2)
    /home/ncw/go/src/github.com/go-python/gpython/repl/web/main.go:82 +0x4
syscall/js.callbackLoop()
    /opt/go/go1.11/src/syscall/js/callback.go:116 +0x7
created by syscall/js.NewCallback.func1
    /opt/go/go1.11/src/syscall/js/callback.go:40 +0x2

output with gopherjs(https://gpython.org/):

Gpython 3.4.0 running in your browser with gopherjs
>>> class A:pass
>>> set(A())
[USER]: https://gpython.org/gpython.js: interface conversion: interface is *py.Type, not py.Tuple
$callDeferred@https://gpython.org/gpython.js:4:22511
$panic@https://gpython.org/gpython.js:4:22957
$assertType@https://gpython.org/gpython.js:4:21361
LM@https://gpython.org/gpython.js:41:325455
MH.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:366934
FK@https://gpython.org/gpython.js:41:255589
DN@https://gpython.org/gpython.js:44:82459
EE.ptr.prototype.Call@https://gpython.org/gpython.js:44:87109
DC@https://gpython.org/gpython.js:44:77098
DO@https://gpython.org/gpython.js:44:91592
DU@https://gpython.org/gpython.js:44:107450
DW@https://gpython.org/gpython.js:44:109015
G.ptr.prototype.Run@https://gpython.org/gpython.js:56:3575
$b@https://gpython.org/gpython.js:60:3908
$b@https://gpython.org/gpython.js:59:2625
r@https://gpython.org/gpython.js:4:23443
$runScheduled@https://gpython.org/gpython.js:4:24007
$schedule@https://gpython.org/gpython.js:4:24184
$go@https://gpython.org/gpython.js:4:23907
I/$packages["github.com/gopherjs/gopherwasm/js"]<@https://gpython.org/gpython.js:59:2240
$externalizeFunction/e.$externalizeWrapper@https://gpython.org/gpython.js:4:28925
a@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:82615
k@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:83463
ENTER@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:14915
$e@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:28362
dispatch@https://code.jquery.com/jquery-latest.js:4641:9
add/elemData.handle@https://code.jquery.com/jquery-latest.js:4309:28


Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions