Skip to content

Clearing a existing dic object leads to Floating point exception #10959

Open
@xiaxinmeng

Description

@xiaxinmeng

The following 'test.py' produces a crash with the unix port. In this example, we clear the dic when defining the dic, then micropython crashes.

test.py

class S(str):

    def __eq__(self, other):
        d.clear()

    def __hash__(self):
        return hash('test')

d = {S(): 'value'}
'test' in d

Error message:

Floating point exception (core dumped)

The expected output: work well (behavior on CPython 3.10.8)

how to replicate it:

  1. install micropython (unix port)
  2. run it with unix port
  3. ->> 'micropython/ports/unix/build-standard/micropython' test.py

Environment
compiler versions: MicroPython v1.19.1-724-gfb7d21153 on 2023-03-07; linux [GCC 7.5.0] version
operating system: Ubuntu 18.04.6 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions