gpython icon indicating copy to clipboard operation
gpython copied to clipboard

Reassignment of 'getattr' leads to gpython crashing

Open xiaxinmeng opened this issue 3 years ago • 2 comments

Reassigning getattr with getattr in a class and then using the attribute 'spam' triggers gpython crashing. See the following example. We test the example on the online gpython i.e., GO/wasm and Gopherjs. GO/wasm can well handle the test while it crashes on the Gopherjs.

test.py


class c(object):
    __getattr__ = getattr
c().spam

Output on Gopherjs (https://gpython.org/)

Gpython 3.4.0 running in your browser with gopherjs
>>> class c(object):
...     __getattr__ = getattr
... 
>>> c().spam
[USER]: https://gpython.org/gpython.js: too much recursion
$assertType@https://gpython.org/gpython.js:4:20889
GL.ptr.prototype.Call@https://gpython.org/gpython.js:41:291927
GL.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:301617
FK@https://gpython.org/gpython.js:41:255589
MH.ptr.prototype.CallMethod@https://gpython.org/gpython.js:41:369579
MP@https://gpython.org/gpython.js:41:370268
MR@https://gpython.org/gpython.js:41:371135
FO@https://gpython.org/gpython.js:41:262478
FP@https://gpython.org/gpython.js:41:264051
P@https://gpython.org/gpython.js:54:33516
GL.ptr.prototype.Call@https://gpython.org/gpython.js:41:292125
GL.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:301617
FK@https://gpython.org/gpython.js:41:255589
MH.ptr.prototype.CallMethod@https://gpython.org/gpython.js:41:369579
MP@https://gpython.org/gpython.js:41:370268
MR@https://gpython.org/gpython.js:41:371135
FO@https://gpython.org/gpython.js:41:262478
FP@https://gpython.org/gpython.js:41:264051
P@https://gpython.org/gpython.js:54:33516
GL.ptr.prototype.Call@https://gpython.org/gpython.js:41:292125
GL.ptr.prototype.M__call__@https://gpython.org/gpython.js:41:301617
FK@https://gpython.org/gpython.js:41:255589
MH.ptr.prototype.CallMethod@https://gpython.org/gpython.js:41:369579
MP@https://gpython.org/gpython.js:41:370268
MR@https://gpython.org/gpython.js:41:371135
FO@https://gpython.org/gpython.js:41:262478
...

xiaxinmeng avatar Dec 05 '22 15:12 xiaxinmeng

I can confirm this on gpython master.

Want to try to fix @xiaxinmeng ?

ncw avatar Dec 05 '22 16:12 ncw

Thanks for confirm these bugs very much. But I am sorry that I cannot fix these bugs because I am not familiar with go language. The fixing task is difficult for me. I will be grateful if you can fix these bugs. Thanks.

xiaxinmeng avatar Dec 07 '22 06:12 xiaxinmeng