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.

classification
Title: m68k struct alignment issue vs. PyException_HEAD
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mirabilos, pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords:

Created on 2013-05-25 21:01 by mirabilos, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
after-patch-1.txt mirabilos, 2013-05-25 21:40
after-patch-2.txt mirabilos, 2013-05-25 21:40
Messages (14)
msg190000 - (view) Author: mirabilos (mirabilos) Date: 2013-05-25 21:01
Hi,

splitting off issue18061 by request of pitrou:

struct alignment issue: PyException_HEAD misses explicit alignment instruction; uses invalid (non-portable) alignment assumptions. ABI change on m68k.

See issue18061 for details.
msg190002 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-25 21:02
> ② This one is pretty severe: AssertionError: 42 != 44 : wrong size for 
> <class 'BaseException'>: got 42, expected 44

What is the context? test_sys?
msg190003 - (view) Author: mirabilos (mirabilos) Date: 2013-05-25 21:03
Yes, that's in test_sys.
msg190006 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-25 21:12
I suppose it's in SizeofTest specifically (in the future, please quote more detailed test information; you can get it by replaying a test in verbose mode, e.g. "./python -m test -v test_sys").

Can you post the output of:

>>> struct.calcsize("PPnP5Pb")

>>> struct.calcsize("PPnP5Pi")

>>> struct.calcsize("PPnP5Pb0P")

>>> struct.calcsize("PPnP5Pi0P")
msg190008 - (view) Author: mirabilos (mirabilos) Date: 2013-05-25 21:18
>>> struct.calcsize("PPnP5Pb")
37
>>> struct.calcsize("PPnP5Pi")
40
>>> struct.calcsize("PPnP5Pb0P")
38
>>> struct.calcsize("PPnP5Pi0P")
40

I already offered to re-run tests in verbose mode “on request” if needed, but the results.txt I attached to issue18061 contains them for test_sys (it apparently got re-run verbosely automatically).
msg190010 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-25 21:23
Ok, can you try applying the following patch:

diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -703,13 +703,13 @@ class SizeofTest(unittest.TestCase):
         class C(object): pass
         check(C.__dict__, size('P'))
         # BaseException
-        check(BaseException(), size('5Pi'))
+        check(BaseException(), size('5Pb'))
         # UnicodeEncodeError
-        check(UnicodeEncodeError("", "", 0, 0, ""), size('5Pi 2P2nP'))
+        check(UnicodeEncodeError("", "", 0, 0, ""), size('5Pb 2P2nP'))
         # UnicodeDecodeError
-        check(UnicodeDecodeError("", b"", 0, 0, ""), size('5Pi 2P2nP'))
+        check(UnicodeDecodeError("", b"", 0, 0, ""), size('5Pb 2P2nP'))
         # UnicodeTranslateError
-        check(UnicodeTranslateError("", 0, 1, ""), size('5Pi 2P2nP'))
+        check(UnicodeTranslateError("", 0, 1, ""), size('5Pb 2P2nP'))
         # ellipses
         check(Ellipsis, size(''))
         # EncodingMap
msg190014 - (view) Author: mirabilos (mirabilos) Date: 2013-05-25 21:40
Sure (attached).
msg190015 - (view) Author: mirabilos (mirabilos) Date: 2013-05-25 21:40
Include/unicodeobject.h has the same problem; its “state” member currently allocates 8 bit, which is only padded up to 16 bit.

asciifields = "nnbP" makes that work too; result attached as after-patch-2.txt

Will just changing the testsuite to match reality be enough, or are there any other internal assumptions about this type of thing, like we had with issue17237 earlier?

Thanks for your quick responses!
msg190016 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-25 21:46
Thank you. This is just a bug in the test suite, so it's fine to fix it.
msg190017 - (view) Author: mirabilos (mirabilos) Date: 2013-05-25 21:48
Okay, then I’ll ignore those for now. Thanks!
msg190018 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-25 21:48
New changeset c20b701c66fc by Antoine Pitrou in branch '3.3':
Issue #18063: fix some struct specifications in the tests for sys.getsizeof().
http://hg.python.org/cpython/rev/c20b701c66fc

New changeset 5c4ca109af1c by Antoine Pitrou in branch 'default':
Issue #18063: fix some struct specifications in the tests for sys.getsizeof().
http://hg.python.org/cpython/rev/5c4ca109af1c
msg190019 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-25 21:52
Should be done now :)
msg190023 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-05-25 22:01
2.7?
msg190025 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-05-25 22:03
2.7 doesn't have the C struct fields which were mistakingly sized in test_sys.
History
Date User Action Args
2022-04-11 14:57:46adminsetgithub: 62263
2013-05-26 06:12:05serhiy.storchakalinkissue18061 dependencies
2013-05-25 22:03:53pitrousetmessages: + msg190025
2013-05-25 22:01:48serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg190023
2013-05-25 21:52:26pitrousetstatus: open -> closed

components: - Interpreter Core
versions: + Python 3.3
messages: + msg190019
type: behavior
resolution: fixed
stage: resolved
2013-05-25 21:48:23python-devsetnosy: + python-dev
messages: + msg190018
2013-05-25 21:48:08mirabilossetmessages: + msg190017
2013-05-25 21:46:21pitrousetmessages: + msg190016
2013-05-25 21:40:10mirabilossetfiles: + after-patch-2.txt

messages: + msg190015
2013-05-25 21:40:01mirabilossetfiles: + after-patch-1.txt

messages: + msg190014
2013-05-25 21:23:52pitrousetmessages: + msg190010
2013-05-25 21:18:47mirabilossetmessages: + msg190008
2013-05-25 21:12:58pitrousetmessages: + msg190006
components: + Tests
versions: + Python 3.4, - Python 3.3
2013-05-25 21:03:30mirabilossetmessages: + msg190003
2013-05-25 21:02:54pitrousetnosy: + pitrou
messages: + msg190002
2013-05-25 21:01:55mirabiloscreate