INADA Naoki <songofaca...@gmail.com> added the comment:

Very thanks!  I found I set `export PYTHONMALLOC=pymalloc_debug`.
That's why I can't reproduce it.

Now I can reproduce and I get where memory is broken, and understood what cause:

Python traceback is:
Traceback (most recent call first):
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 767, in __init__
    self.literal = float(var)
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 646, in __init__
    var_obj = Variable(constant).resolve({})
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 568, in compile_filter
    return FilterExpression(token, self)
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/templatetags/i18n.py",
 line 368, in do_translate
    message_string = parser.compile_filter(bits[1])
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 481, in parse
    compiled_result = compile_func(self, token)
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/loader_tags.py",
 line 233, in do_block
    nodelist = parser.parse(('endblock',))
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 481, in parse
    compiled_result = compile_func(self, token)
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 198, in compile_nodelist
    return parser.parse()
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/base.py",
 line 160, in __init__
    self.nodelist = self.compile_nodelist()
  File 
"/home/inada-n/t/bpo34087/testproj/v38/lib/python3.8/site-packages/django/template/loaders/base.py",
 line 30, in get_template

C traceback is:

#0  0x0000557880378c95 in _Py_string_to_number_with_underscores 
(s=0x7ff07d8e7bc0 "\"So erstellen Sie einen Zahlungslink f?ded_blocks'", 
orig_len=39, what=0x55788046d60a "float",
    obj='"So erstellen Sie einen Zahlungslink für Ihre Rechnung"', 
arg=0x7ff07d9368b0, innerfunc=0x557880276b10 <float_from_string_inner>) at 
Python/pystrtod.c:410
#1  0x0000557880279b23 in PyFloat_FromString (v='"So erstellen Sie einen 
Zahlungslink für Ihre Rechnung"') at Objects/floatobject.c:208
#2  0x0000557880279cd5 in float_new_impl (x=<optimized out>, 
type=0x5578806e4ee0 <PyFloat_Type>) at Objects/floatobject.c:1627
#3  float_new (type=<optimized out>, args=('"So erstellen Sie einen 
Zahlungslink für Ihre Rechnung"',), kwargs=<optimized out>) at 
Objects/clinic/floatobject.c.h:181
#4  0x00005578802cfdc5 in type_call (type=type@entry=0x5578806e4ee0 
<PyFloat_Type>, args=args@entry=('"So erstellen Sie einen Zahlungslink für Ihre 
Rechnung"',), kwds=kwds@entry=0x0)
    at Objects/typeobject.c:929
#5  0x000055788026b3bf in _PyObject_FastCallKeywords 
(callable=callable@entry=<type at remote 0x5578806e4ee0>, stack=<optimized 
out>, nargs=nargs@entry=1, kwnames=kwnames@entry=0x0)
    at Objects/call.c:199
#6  0x00005578802526f4 in call_function (kwnames=0x0, oparg=<optimized out>, 
pp_stack=<synthetic pointer>) at Python/ceval.c:4600
#7  _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at 
Python/ceval.c:3183
#8  0x000055788024fb17 in function_code_fastcall (co=co@entry=0x7ff07ec4f0c0, 
args=<optimized out>, args@entry=0x7ffc786f2330, nargs=2,
    globals=globals@entry={'__name__': 'django.template.base', '__doc__': 
"\nThis is the Django template system.\n\nHow it works:\n\nThe Lexer.tokenize() 
function converts a template string
(i.e., a string containing\nmarkup with custom template tags) to tokens, which 
can be either plain text\n(TOKEN_TEXT), variables (TOKEN_VAR) or block 
statements (TOKEN_BLOCK).\n\nThe Parser(
) class takes a list of tokens in its constructor, and its parse()\nmethod 
returns a compiled template -- which is, under the hood, a list of\nNode 
objects.\n\nEach Node is responsible for c
reating some sort of output -- e.g. simple text\n(TextNode), variable values in 
a given context (VariableNode), results of basic\nlogic (IfNode), results of 
looping (ForNode), or anything el
se. The core Node\ntypes are TextNode, VariableNode, IfNode and ForNode, but 
plugin modules can\ndefine their own custom node types.\n\nEach Node has a 
render() method, which takes a Context
 and returns a string of\nthe rendered node. For example, the render() method 
of a Variable Node ret...(truncated)) at Objects/call.c:283
#9  0x000055788026ad87 in _PyFunction_FastCallDict (func=<function at remote 
0x7ff07ec2f1e0>, args=0x7ffc786f2330, nargs=<optimized out>, kwargs=0x0) at 
Objects/call.c:322
#10 0x000055788026ddc1 in _PyObject_FastCallDict (kwargs=0x0, nargs=2, 
args=0x7ffc786f2330, callable=<function at remote 0x7ff07ec2f1e0>) at 
Objects/call.c:98

----------
title: django: segmentation fault on random places -> float(unicode) may cause 
segmentation fault

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34087>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to