stack

K

Keith Thompson

CBFalconer said:
I don't think I did 'punish'. I told him where to go, in general
terms. He didn't specify his system.

MisterE's response was just "No.", with no elaboration. You appeared
to be defending that response. Perhaps that wasn't your intent.
 
K

Keith Thompson

"Yes, but it's system-specific" is incorrect. On some systems
there is no mechanism to get at the return address.
"There's no portable way to do it" is correct, as it includes
the case of there being no way to do it on some systems.

Well, the function itself must be able to get at the return address in
order to return to it, but that doesn't necessarily mean it's possible
to retrieve that address.

My assumption is that it's always possible, but I could well be
mistaken.
 
K

Keith Thompson

santosh said:
And it must also *behave* like a LIFO data structure. So at least a
software based stack is necessary.

The word "stack" is commonly used in two different ways.

It can refer to a LIFO data structure, regardless of how it's
represented. A C implementation needs one of these to handle
recursive calls, and most likely all calls. (If a program can be
proven to have no recursive calls, an implementation might avoid the
use of a stack; this would make sense only if using a stack led to
relatively inefficent code.)

It can also refer to a specific implementation of a LIFO data
structure, as a contiguous chunk of memory that grows in a particular
direction, typically managed via a hardware stack pointer register.
The phrase "the stack" usually refers to this kind of stack, and I'm
sure it's what the OP was referring to when he said that "the return
address is pushed to the stack". C doesn't require this kind of
stack, and some real-world implementations don't use it.
 
S

santosh

Eric Sosman wrote:

<snip>

An excellent post. Should probably be kept around as a canned response
for the all too frequent topicality debates.
 
R

Richard

Richard Heathfield said:
santosh said:


I agree.


It's considerably less than a year ago that we discussed topicality at some
length. Everyone had a chance to have their say, and many people availed
themselves of that opportunity. I see no reason why it needs to be dragged
up again for the time being. Once a year ought to be enough for anybody.

Are you related to Robert Mugabe by any chance?
 
W

Walter Roberson

Are you related to Robert Mugabe by any chance?

In my opinion, that was a completely unnecessary and extreme insult.

Richard Heathfield expressed an opinion, something that he is
entitled to do in democratic societies. The opinion was not
inherently inflamatory or inherently unreasonable: it was well
within the bounds of what might be believed by a "reasonable person
in full possession of the facts". I have seen no evidence to
suggest that Richard Heathfield is somehow forcing his opinion
upon others or defrauding others or changing rules post facto.

If you disagree with Richard Heathfield about the frequency of
reasonable debate upon topicality, then you could simply state
the frequency which you feel is appropriate and give reasons thereto.
But Richard Heathfield is correct, that the matter did get discussed
at length not long ago, and the majority opinion expressed was in
favour of strict topicality, so be aware that if your answer
about reasonable frequency of topicality debates is "anytime", then
there is a distinct risk that you would be viewed as being unconcerned
with what the majority expressed and instead only interested in
having *your* viewpoint adopted.
 
R

Richard

In my opinion, that was a completely unnecessary and extreme insult.

Get off your high horse. It was a quip. Does your sense of humour not
meet the C Standard and you leave it at the door?
Richard Heathfield expressed an opinion, something that he is
entitled to do in democratic societies. The opinion was not
inherently inflamatory or inherently unreasonable: it was well
within the bounds of what might be believed by a "reasonable person
in full possession of the facts". I have seen no evidence to
suggest that Richard Heathfield is somehow forcing his opinion
upon others or defrauding others or changing rules post facto.

Heathfield trots out the vote thing time after time. The only people
interested enough were the usual c.l.c clique. It proved nothing.
 
F

Flash Gordon

Keith Thompson wrote, On 05/08/08 16:10:
Well, the function itself must be able to get at the return address in
order to return to it, but that doesn't necessarily mean it's possible
to retrieve that address.

My assumption is that it's always possible, but I could well be
mistaken.

I know of one implementation where it is definitely *not* possible
without resort to assembler for all functions and there is not always an
easy way to determine if it is possible. The reason it is not always
possible is that the processor has an 8 deep HW stack for return
addresses which is *not* mapped in to any of the address spaces (it can
only be accessed by call, return, push and pop type assembler
instructions). The compiler will pop return addresses of the stack if
the function calls other functions *unless* it only calls functions from
the provided C library *and* it knows those functions will not cause the
HW stack to overflow. So if a function calls only library functions you
would have to either examine the generated code or determine what the
compiler knows about the library functions which are called to determine
whether the return address is on the HW stack or has been popped of the
HW stack on to the SW stack.

So I would say that on this particular implementation it is impossible
in general without resorting to assembler (as opposed to non-portable C
constructs).

Oh, and this is ignoring the possibility someone else raised that the
function might have been inlined, something that can cause problems with
the non-portable extension provided by at least one implementation for
this purpose :)

OK, now which of these stacks is *the* stack? ;-)
 
W

Walter Roberson

(e-mail address removed)-cnrc.gc.ca (Walter Roberson) writes:
Get off your high horse. It was a quip.

Regardless of what you might have -thought- you were posting, what
you *did* post was (in my opinion) a distinct insult, not a quip.
Personally, I don't believe you intended it as humour.

Heathfield trots out the vote thing time after time. The only people
interested enough were the usual c.l.c clique. It proved nothing.

If you re-examine the postings from that time, I believe you will
find that a large number of people contributed, including a number
that do not contribute very often. It was -not- "the usual c.l.c clique".

Your argument is treading close to the old claim of there being a
"silent majority" that support your position but whom didn't speak up.

If, hypothetically, the strict-topicality stance is what is desired
by the majority of readers, what evidence would you require to
be satisfied that that was the case? What evidence would
be you accept as "proving" something?
 
D

Default User

Walter said:
Regardless of what you might have -thought- you were posting, what
you did post was (in my opinion) a distinct insult, not a quip.
Personally, I don't believe you intended it as humour.

Trolls, feed, don't, please, yadda, yadda.




Brian
 
K

Keith Thompson

CBFalconer said:
You've got it.

MisterE's reply clearly implied that it cannot be done at all. Apart
from being factually incorrect, his reply was off-topic -- unless you
can cite chapter and verse in the ISO C standard to support his
assertion that you can't access a function's return address *even
using non-portable code*.
 
C

CBFalconer

Walter said:
Regardless of what you might have -thought- you were posting,
what you *did* post was (in my opinion) a distinct insult, not
a quip. Personally, I don't believe you intended it as humour.

I suggest plonking "Richard <[email protected]>". Then you will
only see his nonsense in others quotes.
 
A

Antoninus Twink

Regardless of what you might have -thought- you were posting, what
you *did* post was (in my opinion) a distinct insult, not a quip.
Personally, I don't believe you intended it as humour.

When humor cuts close to the bone, there's a fine line between being
funny and being all too true.

It's clear that there are definite parallels: the self-belief in their
unutterable correctness, as well as the nasty methods they use to attack
their enemies - Mugabe phsyically, Heathfield through a continued
undermining of the reputation of his "adversaries" (i.e. those who dare
to disagree with him).
If you re-examine the postings from that time, I believe you will
find that a large number of people contributed, including a number
that do not contribute very often. It was -not- "the usual c.l.c clique".

By your estimation, how many lurkers does this group have for each
regular poster? What, therefore, was the percentage turnout at this
"election" in which Heathfield (like Mugabe) was judge, jury and the
only possible victor?
Your argument is treading close to the old claim of there being a
"silent majority" that support your position but whom didn't speak up.

No less true for being old.
If, hypothetically, the strict-topicality stance is what is desired
by the majority of readers, what evidence would you require to
be satisfied that that was the case? What evidence would
be you accept as "proving" something?

It's impossible to "prove" this either way, just as it's impossible to
say whether the number of babies born in Swaziland yesterday was even
or odd - we have no way of collecting the data.
 
H

Harald van Dijk

Harold Aptroot wrote:
Is it possible to access [the return address] value..??

Of course it is. The OP did not request a standard compliant way to
do it after all
On this newsgroup, there are no non-standard compliant ways to do
anything. Anything of that nature is off=topic,

Please don't use topicality as an excuse or defence for lies.

its not a lie. It's a fact. Your statement is incorrect.

My statement?
There *is* no
standard way to do this and since the topic of this NG is standard C
there is no way to do it that is topical to this NG.

"There is no way to do it that is topical to this NG" and "There is no way
to do it" are very different. The former I have no problem with. The
latter I do, particularly because it suggests that there are no relevant
points to the question outside of the bounds of this group's topicality.
In other words, given "no" as an answer, there is no reason to try asking
on other groups.
Though I must admit
I'd have suggested trying another NG.

That's what I'm after.
 
A

Anand Hariharan

It's considerably less than a year ago that we discussed topicality at some
length. Everyone had a chance to have their say, and many people availed
themselves of that opportunity.

MID please?
 
C

CBFalconer

Keith said:
MisterE's reply clearly implied that it cannot be done at all.
Apart from being factually incorrect, his reply was off-topic --
unless you can cite chapter and verse in the ISO C standard to
support his assertion that you can't access a function's return
address *even using non-portable code*.

I disagree. First, there is nothing from MisterE in the quotes
above, so anything he said is not applicable (nor in my earlier
here-quoted messages). I said 'on this newsgroup' and 'specialized
news-groups dealing with'. I then agreed with Mr. Aptroots
non-enthusiastic comment.

The quotation attributions above seem accurate to me.
 
C

Chris Dollin

Richard said:
Are you related to Robert Mugabe by any chance?

Any doubts I had about you being a deliberate trouble-maker
have been smashed, burnt, and the smoke thrown into the Sun.

If you thought that was /funny/, I have no hope for you.
 
D

David Thompson

jt <[email protected]> wrote:

Actually, it is put in the register "lr" (PPC), "ra" (MIPS), "%o7"
(SPARC), or 14 (IBM S/390; spelled %r14 in GNU assembler). As

S/360,370,390 by convention only; the hardware is equally happy with
any GPR except 0. IIUC zSeries has some new options (insns) also.
others have noted, if fun() is expanded in line, there is no control
transfer at all. But on the VAX and PDP-11, it is indeed placed
on the (hardware) stack.
In PDP-11 it can be pushed, or stored to any of R0 .. R5 and that
register's previous contents pushed (instead). I believe that C on
early-Unix -- around 6/7ed? -- used R5, although if I ever knew why
I've forgotten. (And that's why at most 3 'register' declarations were
effective, using R2..R4, with at least R0&R1 left for expr eval.)

PDP-8 stores it into the first word of the callee routine. But since
the -8 supports at most 48K-octets of storage a conforming C89
implementation would be challenging and C99 out of the question.

- formerly david.thompson1 || achar(64) || worldnet.att.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top