This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年05月05日 13:57 by pitrou, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| socket-aliasing-sas2sa.diff | baikie, 2011年09月18日 19:58 | |||
| socket-aliasing-union-3.2.diff | baikie, 2011年09月18日 19:58 | |||
| socket-aliasing-union-3.3.diff | baikie, 2011年09月18日 19:58 | |||
| Messages (10) | |||
|---|---|---|---|
| msg105033 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2010年05月05日 13:57 | |
This is on py3k, with gcc 4.4.3: /home/antoine/py3k/__svn__/Modules/socketmodule.c: In function 'socket_gethostbyaddr': /home/antoine/py3k/__svn__/Modules/socketmodule.c:3238: warning: dereferencing pointer 'sa' does break strict-aliasing rules /home/antoine/py3k/__svn__/Modules/socketmodule.c:3208: note: initialized from here /home/antoine/py3k/__svn__/Modules/socketmodule.c: In function 'socket_gethostbyname_ex': /home/antoine/py3k/__svn__/Modules/socketmodule.c:3183: warning: dereferencing pointer 'sa' does break strict-aliasing rules /home/antoine/py3k/__svn__/Modules/socketmodule.c:3181: note: initialized from here |
|||
| msg106753 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年05月30日 09:34 | |
Same with gcc 4.4.4, in socket and another file: Modules/_multiprocessing/multiprocessing.c: In function ‘multiprocessing_sendfd’: Modules/_multiprocessing/multiprocessing.c:125: warning: dereferencing type-punned pointer will break strict-aliasing rules Modules/_multiprocessing/multiprocessing.c: In function ‘multiprocessing_recvfd’: Modules/_multiprocessing/multiprocessing.c:168: warning: dereferencing type-punned pointer will break strict-aliasing rules |
|||
| msg139030 - (view) | Author: Kristian Vlaardingerbroek (Kristian.Vlaardingerbroek) | Date: 2011年06月25日 09:22 | |
I can't reproduce both these cases with gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 on i386 using the current default branch (70943:024827a9db64). |
|||
| msg144253 - (view) | Author: David Watson (baikie) | Date: 2011年09月18日 19:58 | |
For reference, the warnings are partially explained here: http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Optimize-Options.html#index-fstrict_002daliasing-825 http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Warning-Options.html#index-Wstrict_002daliasing-337 I get these warnings with GCC (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 [i386], plus an additional one from the new recvmsg() code. I haven't tried GCC 4.5 or later, but as the docs imply, the warnings will not appear in debugging builds. I take it GCC is referring to C99 section 6.5, paragraphs 6 and 7 here, but I'm not sure exactly how much these are intended to prohibit with regard to the (mis)use of unions, or how strictly GCC actually enforces them. The attached socket-aliasing-sas2sa.diff is enough to get rid of the warnings with GCC 4.4.4 - it adds add a "struct sockaddr" member to the sock_addr_t union type, changes the SAS2SA() macro to take the address of this member instead of using a cast, and modifies socket_gethostbyaddr() and socket_gethostbyname_ex() to use SAS2SA() (sock_recvmsg_guts() already uses it). Changing SAS2SA() also gets rid of most of the additional warnings produced by the "aggressive" warning setting -Wstrict-aliasing=2. However, the gethostby* functions still point to the union object with a pointer variable not matching the type actually stored in it, which the GCC docs warn against. To be more conservative, socket-aliasing-union-3.2.diff applies on top to get rid of these pointers, and instead directly access the union for each use other than providing a pointer argument to a function. socket-aliasing-union-recvmsg-3.3.diff does the same for 3.3, and makes the complained-about line in sock_recvmsg_guts() access the union directly as well. One other consideration here is that the different sockaddr_* struct types used are likely to come under the "common initial sequence" rule for unions (C99 6.5.2.3, paragraph 5, or section A8.3 of K&R 2nd ed.), which might make some more questionable uses valid. That said, technically POSIX appears to require only that the s*_family members of the various sockaddr struct types have the same offset and type, not that they form part of a common initial sequence (s*_family need not be the first structure member - the BSDs for instance place it second, although it can still be part of a common initial sequence). |
|||
| msg150171 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2011年12月23日 15:45 | |
New changeset 683a1b1ff15d by Charles-François Natali in branch 'default': Issue #8623: Fix some strict-aliasing warnings. Patch by David Watson. http://hg.python.org/cpython/rev/683a1b1ff15d |
|||
| msg150173 - (view) | Author: Charles-François Natali (neologix) * (Python committer) | Date: 2011年12月23日 15:48 | |
Thanks for your patches, David. I've only applied the first one: looking at the second one, I don't think they are really problems (-Wstrict-aliasing=2 is know for generating a lot of false positives). |
|||
| msg150185 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2011年12月23日 17:17 | |
This change probably should be backported to 3.2 branch. |
|||
| msg150381 - (view) | Author: Charles-François Natali (neologix) * (Python committer) | Date: 2011年12月30日 15:13 | |
> This change probably should be backported to 3.2 branch. I'm not sure about this, I don't feel comfortable backporting a such path which doesn't solve a "real world problem". |
|||
| msg271157 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2016年07月24日 14:38 | |
I think the time for backporting to 3.2 has passed. Is there anything else to do for this report? |
|||
| msg271160 - (view) | Author: Martin Panter (martin.panter) * (Python committer) | Date: 2016年07月24日 14:51 | |
The Modules/_multiprocessing/multiprocessing.c code was removed in 3.3 (Issue 12981). Therefore I am calling this fixed. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:00 | admin | set | github: 52869 |
| 2016年07月24日 14:56:32 | martin.panter | link | issue10036 superseder |
| 2016年07月24日 14:51:23 | martin.panter | set | status: open -> closed resolution: fixed messages: + msg271160 stage: needs patch -> resolved |
| 2016年07月24日 14:38:25 | martin.panter | set | nosy:
+ martin.panter messages: + msg271157 versions: - Python 3.2 |
| 2013年02月01日 21:56:14 | brett.cannon | set | nosy:
- brett.cannon |
| 2011年12月30日 15:13:53 | neologix | set | messages: + msg150381 |
| 2011年12月23日 17:17:56 | Arfrever | set | messages: + msg150185 |
| 2011年12月23日 15:48:09 | neologix | set | nosy:
+ neologix messages: + msg150173 |
| 2011年12月23日 15:45:12 | python-dev | set | nosy:
+ python-dev messages: + msg150171 |
| 2011年09月18日 19:58:58 | baikie | set | files: + socket-aliasing-union-3.3.diff |
| 2011年09月18日 19:58:46 | baikie | set | files: + socket-aliasing-union-3.2.diff |
| 2011年09月18日 19:58:23 | baikie | set | files:
+ socket-aliasing-sas2sa.diff versions: + Python 3.3 nosy: + baikie messages: + msg144253 keywords: + patch |
| 2011年06月25日 09:22:21 | Kristian.Vlaardingerbroek | set | nosy:
+ Kristian.Vlaardingerbroek messages: + msg139030 |
| 2010年06月21日 16:12:35 | Arfrever | set | nosy:
+ Arfrever |
| 2010年05月30日 09:34:05 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg106753 |
| 2010年05月05日 13:57:34 | pitrou | create | |