All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [ TLPI ] bad longjmp example solution redundancy.
       [not found] <CAG2PQ_W=_VJD1LTm+i9HBBWCTn0KRu46arUL5n-3b0EuLFQbpg@mail.gmail.com>
@ 2020-11-18 12:06 ` Michael Kerrisk
  0 siblings, 0 replies; only message in thread
From: Michael Kerrisk @ 2020-11-18 12:06 UTC (permalink / raw)
  To: Robert Kumanek, mtk.manpages, linux-man

Hello Robert,

On 11/17/20 4:24 PM, Robert Kumanek wrote:
> Hi Michael Kerrisk,
> 
> I have run the solution bad_longjmp.c from tlpi-repo and I found it ends
> with seg_fault. It's good, but next I commented partly source code, i.e.
> definition of recur() and its call in main and then after recompilation and
> running it ends also with seg_fault. So I think it was enough to use the
> example without recur(). Maybe I am wrong and it showed something I missed,
> if yes, than what was intention of recur?
> 
> Best wishes and big respect for your work,

It's been a long time since I wrote that program, and nearly as long
since I last tested it, and my memory is a little hazy.

My suspicion is that things have changed (i.e., the compiler is
generating different code these days), with the result that the second
kind of setjmp() error that was shown by this code no longer happens.

If I recall correctly, when the recur() code path was executed (i.e.,
a command-line argument was supplied to the program), then the
longjmp() took us back to one of the still pristine stack frames
from one of the recur() calls, and the program printed out messages
saying that it was now exiting recur() (again), and *then* crashed.
But, that no longer happens.

So, you're right that the recur() code no longer serves any
purpose, and I think I will just delete it.

Thanks for letting me know about this, and I hope you continue
enjoying the book.

Cheers,

Michael

-- 
Michael Kerrisk, man7.org Training and Consulting
mtk@man7.org, http://man7.org/training/
"The Linux Programming Interface" -- http://man7.org/tlpi/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-18 12:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAG2PQ_W=_VJD1LTm+i9HBBWCTn0KRu46arUL5n-3b0EuLFQbpg@mail.gmail.com>
2020-11-18 12:06 ` [ TLPI ] bad longjmp example solution redundancy Michael Kerrisk

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.