New submission from Karthikeyan Singaravelan <tir.kar...@gmail.com>:
I get segfaults on random basis in the below program I wrote for issue41321 while trying to use Ctrl-C to stop the program. I used faulthandler but couldn't get to the exact case where it occurs. I tested it on Python 3.9 from deadsnakes ppa and it crashes. I tried using gdb to get a backtrace but using ctrl-C is caught by gdb. I tried using "handle SIGINT noprint pass" to ensure the ctrl-C is passed to the program by gdb and attached below is a backtrace during a sample segfault. I am wording it as during zoneinfo creation but isolated object creation under an infinite loop where ctrl-c is passed doesn't trigger this. Feel free to modify this as needed and also to add more since I am not good with debugging C issues. import datetime import zoneinfo timezones = zoneinfo.available_timezones() for year in range(1900, 2020): for tz in timezones: d1 = datetime.datetime(year, 5, 4, 7, 13, 22, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp() d2 = datetime.datetime(year, 5, 4, 0, 0, 0, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp() diff = d1 - d2 if diff != 26002: print(year, diff, tz) for tz in timezones: d1 = datetime.datetime(year, 5, 2, 7, 13, 22, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp() d2 = datetime.datetime(year, 5, 2, 0, 0, 0, tzinfo=zoneinfo.ZoneInfo(tz)).timestamp() diff = d1 - d2 if diff != 26002: print("Diff using second day", year, diff, tz) $ python3.9 -X faulthandler ../backups/bpo41321.py ^CFatal Python error: Segmentation fault Current thread 0x00007f23bb2b9740 (most recent call first): File "/root/cpython/../backups/bpo41321.py", line 7 in <module> [1] 1234 segmentation fault (core dumped) python3.9 -X faulthandler ../backups/bpo41321.py Debug build on master branch $ ./python -X faulthandler ../backups/bpo41321.py ^Cpython: Objects/typeobject.c:3244: _PyType_Lookup: Assertion `!PyErr_Occurred()' failed. Fatal Python error: Aborted Current thread 0x00007f28c2256080 (most recent call first): File "/root/cpython/../backups/bpo41321.py", line 14 in <module> [1] 1386 abort (core dumped) ./python -X faulthandler ../backups/bpo41321.py (gdb) r Starting program: /root/cpython/python ../backups/bpo41321.py [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". ^C Program received signal SIGSEGV, Segmentation fault. zoneinfo_no_cache (cls=<optimized out>, args=<optimized out>, kwargs=<optimized out>) at /root/cpython/Modules/_zoneinfo.c:380 380 PyObject *out = zoneinfo_new_instance(cls, key); (gdb) bt #0 zoneinfo_no_cache (cls=<optimized out>, args=<optimized out>, kwargs=<optimized out>) at /root/cpython/Modules/_zoneinfo.c:380 #1 0x00007ffff65ff826 in zoneinfo_new ( type=0x7ffff6801480 <PyZoneInfo_ZoneInfoType>, args=<optimized out>, kw=<optimized out>) at /root/cpython/Modules/_zoneinfo.c:274 #2 0x000055555562a635 in type_call ( type=type@entry=0x7ffff6801480 <PyZoneInfo_ZoneInfoType>, args=args@entry=0x7ffff6fb7520, kwds=kwds@entry=0x0) at Objects/typeobject.c:1020 #3 0x00005555555c3018 in _PyObject_MakeTpCall ( tstate=tstate@entry=0x555555b2c350, callable=callable@entry=0x7ffff6801480 <PyZoneInfo_ZoneInfoType>, args=args@entry=0x7ffff6f20df8, nargs=<optimized out>, keywords=0x0) at Objects/call.c:191 #4 0x00005555555ab48b in _PyObject_VectorcallTstate (kwnames=<optimized out>, nargsf=<optimized out>, args=<optimized out>, callable=<optimized out>, tstate=<optimized out>) at ./Include/cpython/abstract.h:112 #5 PyObject_Vectorcall (kwnames=<optimized out>, nargsf=<optimized out>, args=<optimized out>, callable=<optimized out>) at ./Include/cpython/abstract.h:123 #6 call_function (tstate=tstate@entry=0x555555b2c350, pp_stack=pp_stack@entry=0x7fffffffdf30, oparg=<optimized out>, kwnames=kwnames@entry=0x0) at Python/ceval.c:5121 #7 0x00005555555b17dd in _PyEval_EvalFrameDefault (tstate=<optimized out>, f=<optimized out>, throwflag=<optimized out>) at Python/ceval.c:3516 #8 0x00005555556864f5 in _PyEval_EvalFrame (throwflag=0, f=0x7ffff6f20c40, tstate=0x555555b2c350) at ./Include/internal/pycore_ceval.h:40 #9 _PyEval_EvalCode (qualname=0x7ffff6e860f0, name=0x7ffff6e860f0, closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwstep=2, kwcount=0, kwargs=0x0, kwnames=0x0, argcount=0, args=0x0, locals=0x0, globals=0x555555b2c350, _co=0x7ffff6ee6d40, tstate=0x555555b2c350) at Python/ceval.c:4376 #10 _PyEval_EvalCodeWithName (qualname=0x0, name=0x0, closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwstep=2, kwcount=0, kwargs=0x0, kwnames=0x0, argcount=0, args=0x0, locals=locals@entry=0x0, globals=globals@entry=0x555555b2c350, _co=0x7ffff6ee6d40, _co@entry=0x7ffff6f20da0) at Python/ceval.c:4408 #11 PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0, locals=locals@entry=0x0, globals=globals@entry=0x555555b2c350, _co=0x7ffff6ee6d40, _co@entry=0x7ffff6f20da0) at Python/ceval.c:4424 ---Type <return> to continue, or q <return> to quit--- #12 PyEval_EvalCode (co=co@entry=0x7ffff6ee6d40, globals=globals@entry=0x7ffff6f4e440, locals=locals@entry=0x7ffff6f4e440) at Python/ceval.c:857 #13 0x00005555556d69c6 in run_eval_code_obj (locals=0x7ffff6f4e440, globals=0x7ffff6f4e440, co=0x7ffff6ee6d40, tstate=0x555555b2c350) at Python/pythonrun.c:1124 #14 run_mod (arena=0x7ffff6fa1910, flags=0x7fffffffe128, locals=0x7ffff6f4e440, globals=0x7ffff6f4e440, filename=0x7ffff6e815d0, mod=<optimized out>) at Python/pythonrun.c:1145 #15 PyRun_FileExFlags (fp=fp@entry=0x555555b89b40, filename_str=filename_str@entry=0x7ffff6f5a050 "/root/cpython/../backups/bpo41321.py", start=start@entry=257, globals=globals@entry=0x7ffff6f4e440, locals=locals@entry=0x7ffff6f4e440, closeit=closeit@entry=1, flags=0x7fffffffe128) at Python/pythonrun.c:1062 #16 0x00005555556d6b9d in PyRun_SimpleFileExFlags (fp=fp@entry=0x555555b89b40, filename=<optimized out>, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe128) at Python/pythonrun.c:397 #17 0x00005555556d70e3 in PyRun_AnyFileExFlags (fp=fp@entry=0x555555b89b40, filename=<optimized out>, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffe128) at Python/pythonrun.c:80 #18 0x00005555555b52a0 in pymain_run_file (cf=0x7fffffffe128, config=0x555555b28db0) at Modules/main.c:369 #19 pymain_run_python (exitcode=0x7fffffffe11c) at Modules/main.c:594 #20 Py_RunMain () at Modules/main.c:673 #21 0x00005555555b57d6 in pymain_main (args=0x7fffffffe210) at Modules/main.c:703 #22 Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:727 #23 0x00007ffff7041b97 in __libc_start_main (main=0x5555555aa2b0 <main>, argc=2, argv=0x7fffffffe368, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe358) at ../csu/libc-start.c:310 #24 0x00005555555b446a in _start () ---------- messages: 373912 nosy: belopolsky, p-ganssle, serhiy.storchaka, xtreak priority: normal severity: normal status: open title: Random segfaults during zoneinfo object creation stopped using Ctrl-C type: crash versions: Python 3.10, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41336> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com