aboutsummaryrefslogtreecommitdiff
path: root/Source/Evolve/WarpXEvolve.cpp
diff options
context:
space:
mode:
authorGravatar Axel Huebl <axel.huebl@plasma.ninja> 2022-01-18 11:38:39 -0800
committerGravatar GitHub <noreply@github.com> 2022-01-18 11:38:39 -0800
commitd3e17e7f7402ddc41272784cd5dd202eb6f7e4cd (patch)
treefc1c8bb83db842cbe7ad575a1b4c39dd4d163a5c /Source/Evolve/WarpXEvolve.cpp
parent988cb01e64eb5677e3ac1f4c0d70dcf3c4b2ea3b (diff)
downloadWarpX-d3e17e7f7402ddc41272784cd5dd202eb6f7e4cd.tar.gz
WarpX-d3e17e7f7402ddc41272784cd5dd202eb6f7e4cd.tar.zst
WarpX-d3e17e7f7402ddc41272784cd5dd202eb6f7e4cd.zip
Python: Fix UB in Inputs Passing (#2726)
Trying to fix the macOS PyPy 3.7 error seen in https://github.com/conda-forge/warpx-feedstock/issues/37 Testing in https://github.com/conda-forge/warpx-feedstock/pull/38 After googling for a while, the original implementation was likely based on https://code.activestate.com/lists/python-list/704158, which contains bugs. 1) Bug: `create_string_buffer` Allocating new, null-terminated char arrays with `ctypes.create_string_buffer` does lead to scrambled arrays in pypy3.7. As far as I can see, this [should have also worked](https://docs.python.org/3/library/ctypes.html), but maybe there is a bug in the upstream implementation or the original code created some kind of use-after-free on a temporary while the new implementation just shares the existing byte address. This leads to errors such as the ones here: https://github.com/conda-forge/warpx-feedstock/pull/38#issuecomment-1010160519 The call `argvC[i] = ctypes.c_char_p(enc_arg)` is equivalent in creating a `NULL`-terminated char array. 2) Bug: Last Argv Argument The last argument in the array of char arrays `argv` in ANSII C needs to be a plain `NULL` ptr. Before this PR, this has been allocated but never initialized, leading to undefined behavior (read as: crashes). Reference: https://stackoverflow.com/a/39096006/2719194 3) Cleanup: there is a pre-defined `ctypes.c_char_p` we can use for pointer of char.
Diffstat (limited to 'Source/Evolve/WarpXEvolve.cpp')
0 files changed, 0 insertions, 0 deletions