python2.7 throws bus error when issuing `help("modules")'
ryandesign at macports.org
Mon Aug 24 18:15:30 UTC 2020
On Aug 24, 2020, at 10:36, Jeffrey Waltonwrote:
> On Mon, Aug 24, 2020 at 5:59 AM Ryan Schmidt wrote:
>>> Logical CPU: 2
>>> Error Code: 0x00000007 (invalid protections for user data read)
>>> Trap Number: 14
>>> do you see the problem? I don't :|
> I see the fix came from
> https://github.com/ronaldoussoren/pyobjc/pull/301/files. I don't think
> that fix is correct. I think the use is going to give you more trouble
> over time.
> You can't cast a const object to non-const and write to it. The
> non-const cast is undefined behavior because the object is const. (You
> can only cast a non-const object back to non-const).
> I think a more correct (?) fix would be to track the const-ness of the
> actual object. That is:
> static BOOL is_default_descr(struct _PyObjC_ArgDescr* descr)
> needs a way to look at _PyObjC_ArgDescr descr, and determine if it is
> a non-const object. I think there are (at least) two ways to do it.
> First, add a new field to _PyObjC_ArgDescr. Second, and a new
> parameter to is_default_descr. I don't know which is best.
I don't follow what you're saying. The patch/PR doesn't cast anything. All that's being changed by the patch/PR is that we no longer attempt to write (to the read-only memory) if the value would not change. Dan found that this fixed the problem for py36/py37/py38 before he committed it 7 months ago, and I confirmed that it fixed the crash on py27/py35 before I committed it today.
The pull request was accepted by the developers and included in PyObjC 6.2.1, though I see that it was modified slightly:
I'm not familiar with the code and I have not attempted to analyze the function to convince myself that the change is equivalent.
If you believe PyObjC should do something differently, please take it up with the developers of PyObjC.
More information about the macports-users