New submission from Francesc Elies <francesc.el...@gmail.com>:

Hi,

Context
=======
we are compiling a dll with clang and it's address sanitizer and loading it via 
cffi, at random spots ASAN complains with bad-free.

      ==15100==ERROR: AddressSanitizer: attempting free on address which was 
not malloc()-ed: 0x01991a850310 in thread T0
          #0 0x7ffa1dcc7f31  
(C:\LLVM-13.0.0-win64\lib\clang\13.0.0\lib\windows\clang_rt.asan_dynamic-x86_64.dll+0x180037f31)
          #1 0x7ffa3aea59ec in _PyObject_Realloc 
D:\_w\1\s\Objects\obmalloc.c:2011
          #2 0x7ffa3af7f347 in _PyObject_GC_Resize 
D:\_w\1\s\Modules\gcmodule.c:2309
          #3 0x7ffa3aedeeaa in _PyEval_EvalCode D:\_w\1\s\Python\ceval.c:4101
          ...
          See links below for a full trace

The project where we see this it's quite complex and with many moving parts 
therefore we made a minimal reproducible example.

Reprex
======

The test boils down to the following:

    
win32api.LoadLibrary("LLVM-13.0.0-win64/lib/clang/13.0.0/lib/windows/clang_rt.asan_dynamic-x86_64.dll")
    import hello  # hello is our compiled c extension with clang and ASAN
    print(hello.system())
    import pdb


If if comment the last line (import pdb) ASAN does not complain.
If instead of import pdb you import numpy the same problem can be seen.

See the following failing build 
https://github.com/FrancescElies/min_reprex_python_c_extension_asan/runs/4263693010?check_suite_focus=true
See here the CI test 
https://github.com/FrancescElies/min_reprex_python_c_extension_asan/blob/d966d3a472df71977dc6519a76be0120d2d58d39/test.py


We did not try this in linux yet, would that help?

Is this a bug? Or are we doing something wrong?

Thanks in advance for your time.

----------
components: Windows
messages: 406578
nosy: FrancescElies, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: AddressSanitizer: bad-free  -  hello world c extension
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

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

Reply via email to