* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
[not found] ` <E1ZlgVQ-0004gO-Em@vcs.savannah.gnu.org>
@ 2015-10-13 1:07 ` Stefan Monnier
2015-10-13 2:42 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2015-10-13 1:07 UTC (permalink / raw)
To: emacs-devel; +Cc: Eli Zaretskii
> Attempt to avoid crashes in plist-member
> * src/fns.c (Fplist_member): Don't call QUIT between a CONSP test
> and a call to XCDR. (Bug#21655)
I have no objection to the patch itself, but I must say that I wonder
how it can avoid crashes. IOW why would calling QUIT between a CONSP test
and a call to XCDR be dangerous?
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 1:07 ` [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member Stefan Monnier
@ 2015-10-13 2:42 ` Eli Zaretskii
2015-10-13 3:36 ` Paul Eggert
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Eli Zaretskii @ 2015-10-13 2:42 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Eli Zaretskii <eliz@gnu.org>
> Date: Mon, 12 Oct 2015 21:07:00 -0400
>
> > Attempt to avoid crashes in plist-member
>
> > * src/fns.c (Fplist_member): Don't call QUIT between a CONSP test
> > and a call to XCDR. (Bug#21655)
>
> I have no objection to the patch itself, but I must say that I wonder
> how it can avoid crashes. IOW why would calling QUIT between a CONSP test
> and a call to XCDR be dangerous?
QUIT could call some Lisp.
How else would you explain a segfault in that loop?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 2:42 ` Eli Zaretskii
@ 2015-10-13 3:36 ` Paul Eggert
2015-10-13 14:58 ` Eli Zaretskii
2015-10-13 8:00 ` Andreas Schwab
2015-10-13 10:26 ` David Kastrup
2 siblings, 1 reply; 16+ messages in thread
From: Paul Eggert @ 2015-10-13 3:36 UTC (permalink / raw)
To: Eli Zaretskii, Stefan Monnier; +Cc: emacs-devel
Eli Zaretskii wrote:
> QUIT could call some Lisp.
Sure, but Lisp cannot affect the value of CONSP (plist).
> How else would you explain a segfault in that loop?
It's not clear the code is in that loop. It could merely be
RtlCaptureStackBackTrace misbehaving, no?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 2:42 ` Eli Zaretskii
2015-10-13 3:36 ` Paul Eggert
@ 2015-10-13 8:00 ` Andreas Schwab
2015-10-13 15:01 ` Eli Zaretskii
2015-10-13 10:26 ` David Kastrup
2 siblings, 1 reply; 16+ messages in thread
From: Andreas Schwab @ 2015-10-13 8:00 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Cc: Eli Zaretskii <eliz@gnu.org>
>> Date: Mon, 12 Oct 2015 21:07:00 -0400
>>
>> > Attempt to avoid crashes in plist-member
>>
>> > * src/fns.c (Fplist_member): Don't call QUIT between a CONSP test
>> > and a call to XCDR. (Bug#21655)
>>
>> I have no objection to the patch itself, but I must say that I wonder
>> how it can avoid crashes. IOW why would calling QUIT between a CONSP test
>> and a call to XCDR be dangerous?
>
> QUIT could call some Lisp.
>
> How else would you explain a segfault in that loop?
The only chance I see if garbage collection mistakenly collects the
referenced cell. But that wouldn't be cured by the change.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 2:42 ` Eli Zaretskii
2015-10-13 3:36 ` Paul Eggert
2015-10-13 8:00 ` Andreas Schwab
@ 2015-10-13 10:26 ` David Kastrup
2015-10-13 13:23 ` Stefan Monnier
2015-10-13 15:16 ` Eli Zaretskii
2 siblings, 2 replies; 16+ messages in thread
From: David Kastrup @ 2015-10-13 10:26 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Stefan Monnier <monnier@iro.umontreal.ca>
>> Cc: Eli Zaretskii <eliz@gnu.org>
>> Date: Mon, 12 Oct 2015 21:07:00 -0400
>>
>> > Attempt to avoid crashes in plist-member
>>
>> > * src/fns.c (Fplist_member): Don't call QUIT between a CONSP test
>> > and a call to XCDR. (Bug#21655)
>>
>> I have no objection to the patch itself, but I must say that I wonder
>> how it can avoid crashes. IOW why would calling QUIT between a CONSP test
>> and a call to XCDR be dangerous?
>
> QUIT could call some Lisp.
Sure, but it would not return. So the XCDR should not be an issue.
> How else would you explain a segfault in that loop?
Have you configured with
--no-thread-jumps
?
'-fthread-jumps'
Perform optimizations that check to see if a jump branches to a
location where another comparison subsumed by the first is found.
If so, the first branch is redirected to either the destination of
the second branch or a point immediately following it, depending on
whether the condition is known to be true or false.
Enabled at levels '-O2', '-O3', '-Os'.
Because when jumps/calls are threaded, most particularly to functions
the compiler knows not to return, the backtraces may point to unrelated
code and with nonsensical local variable settings.
--
David Kastrup
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 10:26 ` David Kastrup
@ 2015-10-13 13:23 ` Stefan Monnier
2015-10-13 13:41 ` David Kastrup
2015-10-13 15:16 ` Eli Zaretskii
1 sibling, 1 reply; 16+ messages in thread
From: Stefan Monnier @ 2015-10-13 13:23 UTC (permalink / raw)
To: David Kastrup; +Cc: Eli Zaretskii, emacs-devel
>> QUIT could call some Lisp.
> Sure, but it would not return.
Actually, QUIT can run Elisp and return (the `quit' signal is the only
signal that can do that).
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 13:23 ` Stefan Monnier
@ 2015-10-13 13:41 ` David Kastrup
0 siblings, 0 replies; 16+ messages in thread
From: David Kastrup @ 2015-10-13 13:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>>> QUIT could call some Lisp.
>> Sure, but it would not return.
>
> Actually, QUIT can run Elisp and return (the `quit' signal is the only
> signal that can do that).
I have my doubt this could be the cause of the problem: between CONSP
and XCDR the value has to be kept somewhere: in a register or on the
stack. If Lisp code were running garbage collection in between, this
cons cell would be protected due to its presence in the stack frame.
The only plausible explanation I'd have is that CONSP happens to be true
(due to the set bits in the value) but the value is garbage anyway and
points nowhere sane. In that case, any intermittent QUIT call would be
a red herring: the XCDR would bork on the value anyway.
--
David Kastrup
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 3:36 ` Paul Eggert
@ 2015-10-13 14:58 ` Eli Zaretskii
2015-10-13 15:08 ` David Kastrup
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Eli Zaretskii @ 2015-10-13 14:58 UTC (permalink / raw)
To: Paul Eggert; +Cc: monnier, emacs-devel
> Cc: emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Mon, 12 Oct 2015 20:36:06 -0700
>
> QUIT could call some Lisp.
>
> Sure, but Lisp cannot affect the value of CONSP (plist).
Not the value of CONSP, the list itself. We follow the CONSP test
with XCAR, which crashed. The only way I could imagine that happening
is that the list got modified between the test and the XCAR call. Is
there any other way to explain that?
> How else would you explain a segfault in that loop?
>
> It's not clear the code is in that loop.
The address clearly points to Fplist_member at fns.c:2879.
> It could merely be RtlCaptureStackBackTrace misbehaving, no?
I don't think so. It could be something else, though: the segfault
could have happened in another thread while the Lisp thread was in
plist-member.
But the change I made cannot do any harm, and it tried to use the only
evidence I had from the report. The alternative was to do nothing at
all.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 8:00 ` Andreas Schwab
@ 2015-10-13 15:01 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2015-10-13 15:01 UTC (permalink / raw)
To: Andreas Schwab; +Cc: monnier, emacs-devel
> From: Andreas Schwab <schwab@suse.de>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
> Date: Tue, 13 Oct 2015 10:00:26 +0200
>
> > QUIT could call some Lisp.
> >
> > How else would you explain a segfault in that loop?
>
> The only chance I see if garbage collection mistakenly collects the
> referenced cell. But that wouldn't be cured by the change.
Couldn't some atimer call some (possibly advised) Lisp, which could
change the list that is being iterated through?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 14:58 ` Eli Zaretskii
@ 2015-10-13 15:08 ` David Kastrup
2015-10-13 15:32 ` Eli Zaretskii
2015-10-13 15:21 ` Paul Eggert
2015-10-13 19:05 ` Stefan Monnier
2 siblings, 1 reply; 16+ messages in thread
From: David Kastrup @ 2015-10-13 15:08 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Paul Eggert, monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> Cc: emacs-devel@gnu.org
>> From: Paul Eggert <eggert@cs.ucla.edu>
>> Date: Mon, 12 Oct 2015 20:36:06 -0700
>>
>> QUIT could call some Lisp.
>>
>> Sure, but Lisp cannot affect the value of CONSP (plist).
>
> Not the value of CONSP, the list itself. We follow the CONSP test
> with XCAR, which crashed. The only way I could imagine that happening
> is that the list got modified between the test and the XCAR call. Is
> there any other way to explain that?
Huh? CONSP only checks some bits on a pointer. It does not verify that
the pointer can be dereferenced into an existing cons cell. So there is
absolutely no need to modify anything between having a true CONSP test
and a crashing XCAR.
--
David Kastrup
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 10:26 ` David Kastrup
2015-10-13 13:23 ` Stefan Monnier
@ 2015-10-13 15:16 ` Eli Zaretskii
1 sibling, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2015-10-13 15:16 UTC (permalink / raw)
To: David Kastrup; +Cc: monnier, emacs-devel
> From: David Kastrup <dak@gnu.org>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
> Date: Tue, 13 Oct 2015 12:26:11 +0200
>
> > QUIT could call some Lisp.
>
> Sure, but it would not return. So the XCDR should not be an issue.
I meant via atimers. Those do return.
> Have you configured with
>
> --no-thread-jumps
>
> ?
>
> '-fthread-jumps'
> Perform optimizations that check to see if a jump branches to a
> location where another comparison subsumed by the first is found.
> If so, the first branch is redirected to either the destination of
> the second branch or a point immediately following it, depending on
> whether the condition is known to be true or false.
>
> Enabled at levels '-O2', '-O3', '-Os'.
I think that build is not optimized at all.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 14:58 ` Eli Zaretskii
2015-10-13 15:08 ` David Kastrup
@ 2015-10-13 15:21 ` Paul Eggert
2015-10-13 15:34 ` Eli Zaretskii
2015-10-13 19:05 ` Stefan Monnier
2 siblings, 1 reply; 16+ messages in thread
From: Paul Eggert @ 2015-10-13 15:21 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii wrote:
> The only way I could imagine that happening
> is that the list got modified between the test and the XCAR call.
As David mentioned, no modification to the list can explain a crashed XCAR if a
valid CONSP succeeded.
>> >It's not clear the code is in that loop.
> The address clearly points to Fplist_member at fns.c:2879.
Yes, but that part of the backtrace looks wrong. Why would Fplist_member be
calling itself recursively? Most likely the backtrace is bogus and the patch
irrelevant.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 15:08 ` David Kastrup
@ 2015-10-13 15:32 ` Eli Zaretskii
2015-10-13 15:50 ` David Kastrup
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2015-10-13 15:32 UTC (permalink / raw)
To: David Kastrup; +Cc: eggert, monnier, emacs-devel
> From: David Kastrup <dak@gnu.org>
> Cc: Paul Eggert <eggert@cs.ucla.edu>, monnier@iro.umontreal.ca, emacs-devel@gnu.org
> Date: Tue, 13 Oct 2015 17:08:52 +0200
>
> CONSP only checks some bits on a pointer. It does not verify that
> the pointer can be dereferenced into an existing cons cell. So there is
> absolutely no need to modify anything between having a true CONSP test
> and a crashing XCAR.
Yes, well... I didn't have such a serious calamity in mind.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 15:21 ` Paul Eggert
@ 2015-10-13 15:34 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2015-10-13 15:34 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
> Cc: emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Tue, 13 Oct 2015 08:21:27 -0700
>
> >> >It's not clear the code is in that loop.
> > The address clearly points to Fplist_member at fns.c:2879.
>
> Yes, but that part of the backtrace looks wrong. Why would Fplist_member be
> calling itself recursively?
No, the backtrace doesn't say that. There are 2 separate backtraces
lumped into a single file, that's all.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 15:32 ` Eli Zaretskii
@ 2015-10-13 15:50 ` David Kastrup
0 siblings, 0 replies; 16+ messages in thread
From: David Kastrup @ 2015-10-13 15:50 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: eggert, monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: David Kastrup <dak@gnu.org>
>> Cc: Paul Eggert <eggert@cs.ucla.edu>, monnier@iro.umontreal.ca,
>> emacs-devel@gnu.org
>> Date: Tue, 13 Oct 2015 17:08:52 +0200
>>
>> CONSP only checks some bits on a pointer. It does not verify that
>> the pointer can be dereferenced into an existing cons cell. So there is
>> absolutely no need to modify anything between having a true CONSP test
>> and a crashing XCAR.
>
> Yes, well... I didn't have such a serious calamity in mind.
Shrug. An accidental collection when the value is currently in a local
variable clearly having to end up in the stack frame seems less likely
to me than an accidental collection at a time when the value was not in
active use but likely only stored in some heap data structure. Who
marks the structures in those?
If the calamity is indeed premature collection rather than a random
value that was never valid to start with.
--
David Kastrup
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member
2015-10-13 14:58 ` Eli Zaretskii
2015-10-13 15:08 ` David Kastrup
2015-10-13 15:21 ` Paul Eggert
@ 2015-10-13 19:05 ` Stefan Monnier
2 siblings, 0 replies; 16+ messages in thread
From: Stefan Monnier @ 2015-10-13 19:05 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Paul Eggert, emacs-devel
> Not the value of CONSP, the list itself. We follow the CONSP test
> with XCAR, which crashed. The only way I could imagine that happening
> is that the list got modified between the test and the XCAR call. Is
> there any other way to explain that?
The result of the CONSP test shouldn't be affected by anything at all
(it's basically testing some bit-pattern on the integer value stored in
the local variable, so no external code should be able to change it
since we don't pass any reference to that variable anywhere).
So doing moving the CONSP test before/after the QUIT shouldn't make any
difference. Of course, if the Lisp_Object value is a reference to
a cons cell that got GC'd away, CONSP will still return true while XCAR
could crash or return garbage. Similarly, if the Lisp_Object value is
garbage, CONSP might return true while XCAR might crash (or return
further garbage).
I think the symptoms you describe seem to indicate that we have
a problem where the GC collected a cons cell that was still in use
(otherwise, if CONSP is true, than XCAR should not crash, no matter what
happens between the two).
Stefan
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-10-13 19:05 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20151012170324.17966.77@vcs.savannah.gnu.org>
[not found] ` <E1ZlgVQ-0004gO-Em@vcs.savannah.gnu.org>
2015-10-13 1:07 ` [Emacs-diffs] master 8ba156f: Attempt to avoid crashes in plist-member Stefan Monnier
2015-10-13 2:42 ` Eli Zaretskii
2015-10-13 3:36 ` Paul Eggert
2015-10-13 14:58 ` Eli Zaretskii
2015-10-13 15:08 ` David Kastrup
2015-10-13 15:32 ` Eli Zaretskii
2015-10-13 15:50 ` David Kastrup
2015-10-13 15:21 ` Paul Eggert
2015-10-13 15:34 ` Eli Zaretskii
2015-10-13 19:05 ` Stefan Monnier
2015-10-13 8:00 ` Andreas Schwab
2015-10-13 15:01 ` Eli Zaretskii
2015-10-13 10:26 ` David Kastrup
2015-10-13 13:23 ` Stefan Monnier
2015-10-13 13:41 ` David Kastrup
2015-10-13 15:16 ` Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.