[issue22171] stack smash when using ctypes/libffi to access union
Sam Kerr added the comment: I was also able to get the stack smashing behavior with the following: OS: Linux slaptop 4.19.12-arch1-1-ARCH #1 SMP PREEMPT Fri Dec 21 13:56:54 UTC 2018 x86_64 GNU/Linux GCC: gcc (GCC) 8.2.1 20181127 I was able to track down the issue into the src/x86/ffi64.c file inside libffi. Because more than 4 (the #define'd MAX_CLASSES value in libffi) items were passed, libffi writes outside an array boundary, which is what causes the stack smashing. I forked libffi and added an assert to prove this is what is happening. You can find it at https://github.com/stkerr/libffi/commit/80bca6647702ffd846c655be14d8306ef24ca2dd. Just as a quick test, I tried to increase the MAX_CLASSES value to 40, which is far more than the 9 in the crashing example. I'm 99% positive changing the MAX_CLASSES magic value isn't the right way to solve this issue, but it may give a hint on the proper way to address it. I'm not sure at this point if this behavior is something for libffi to fix or how Python calls libffi though. I'll keep looking, but hopefully this helps someone else make some progress. -- nosy: +Sam.Kerr ___ Python tracker <https://bugs.python.org/issue22171> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22047] argparse improperly prints mutually exclusive options when they are in a group
Sam Kerr added the comment: I fat fingered the example, sorry: [ [ -opt1 | -opt2 | -opt3 ] | [ [-opt4] [-opt5] [-opt6] ] ] Note the new pipe between the 2 subgroups -- ___ Python tracker <http://bugs.python.org/issue22047> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22047] argparse improperly prints mutually exclusive options when they are in a group
Sam Kerr added the comment: What I was going for was the ability to have a group contain a mutually exclusive group and a non-exclusive group, but using the mutually exclusive group meant you could not use the non-exclusive group. Such as: [ [ -opt1 | -opt2 | -opt3 ] [ [-opt4] [-opt5] [-opt6] ] ] -- ___ Python tracker <http://bugs.python.org/issue22047> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22047] argparse improperly prints mutually exclusive options when they are in a group
New submission from Sam Kerr: The following code: import argparse parser = argparse.ArgumentParser() group1 = parser.add_mutually_exclusive_group() group2 = group1.add_mutually_exclusive_group() group2.add_argument('-hello',action='store_true', help="A flag") args = parser.parse_args() produces this output: skerr@gravel:~$ python bug.py -h usage: bug.py [-h] [[-hello] optional arguments: -h, --help show this help message and exit -hello A flag skerr@gravel:~$ Note the double [[ around hello, but there is no double ]] to close it. This is the error. -- components: Library (Lib) messages: 223744 nosy: Sam.Kerr priority: normal severity: normal status: open title: argparse improperly prints mutually exclusive options when they are in a group type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue22047> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com