Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching datetime crashes Python 2.7.13,2.7.14 on Debian/Ubuntu #22

Open
evanj opened this issue Dec 17, 2017 · 3 comments
Open

Patching datetime crashes Python 2.7.13,2.7.14 on Debian/Ubuntu #22

evanj opened this issue Dec 17, 2017 · 3 comments

Comments

@evanj
Copy link

evanj commented Dec 17, 2017

The following program crashes Python with various memory corruption related errors on Debian 9 and Ubuntu 17.10. The program works fine on my Mac.

forbiddenfruit version 0.1.2 installed with pip install forbiddenfruit

Working system

  • Mac OS X 10.13.2; Python 2.7.10 (shipped by Apple)

Failing systems

  • Debian 9.3; Python 2.7.13 2.7.13-2+deb9u2
  • Ubuntu 16.04.3 LTS; Python 2.7.12 2.7.12-1ubuntu0~16.04.2
  • Ubuntu 17.10; Python 2.7.14 2.7.14-2ubuntu2

Reproducing the errors

On a new virtual machine, run the following:

sudo apt-get install gcc libpython2.7-dev virtualenv
virtualenv bugvenv
bugvenv/bin/pip install forbiddenfruit
bugvenv/bin/python bug.py

Example failing output

before datetime.now: 2017-12-17 15:03:16.985094
after datetime.now: 2017-12-17 15:03:16.985267
before datetime.now: 2017-12-17 15:03:16.985314
Traceback (most recent call last):
  File "bug.py", line 21, in <module>
    activate_deactivate()
  File "bug.py", line 14, in activate_deactivate
    f = datetime.datetime.now()
TypeError: &traceback' object is not callable
Fatal Python error: Inconsistent interned string state.
Aborted

Correct output

before datetime.now: 2017-12-17 10:04:33.392523
after datetime.now: 2017-12-17 15:04:33.392366
before datetime.now: 2017-12-17 15:04:33.392366
after datetime.now: 2017-12-17 15:04:33.392366
before datetime.now: 2017-12-17 15:04:33.392366
after datetime.now: 2017-12-17 15:04:33.392366

Script

import datetime
import forbiddenfruit


datetime_now = datetime.datetime.utcnow()
def fake_now(cls):
    return datetime_now


def activate_deactivate():
    now = datetime.datetime.now()
    print 'before datetime.now:', now
    forbiddenfruit.curse(datetime.datetime, 'now', classmethod(fake_now))
    f = datetime.datetime.now()
    print 'after datetime.now:', f


if __name__ == '__main__':
    for i in xrange(3):
        activate_deactivate()
@Arnie97
Copy link

Arnie97 commented May 18, 2019

Seems Python 2-specific. The same script works on Debian 9 with Python 3.5.3 (after replacing print and xrange with their Python 3 counterpart, of course).

@clarete
Copy link
Owner

clarete commented May 21, 2019

Hehehe I can wait til the end of the year to close this lol

@evanj
Copy link
Author

evanj commented May 22, 2019

At this point, that is probably a reasonable strategy :)

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

No branches or pull requests

3 participants