Skip to content

Segmentation fault in time_machine_travel(timedelta()) #431

@marcinsulikowski

Description

@marcinsulikowski

Python Version

3.12

pytest Version

No response

Package Version

2.14.0

Description

The following Python script:

from datetime import timedelta
import time_machine

with time_machine.travel(timedelta()):
    pass

crashes due to a segmentation fault in the constructor of the travel class.

The crash happens when the constructor tries to determine the destination timestamp like this:

    timestamp = time() + dest.total_seconds()

where time() calls result = _time_machine.original_time() which crashes if time_machine's patches are not applied yet and thus the original_time function pointer is still NULL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions