* [9fans] debugging help asked for
@ 2007-05-21 11:32 cej
2007-05-21 13:36 ` Richard Miller
2007-05-22 10:43 ` Charles Forsyth
0 siblings, 2 replies; 5+ messages in thread
From: cej @ 2007-05-21 11:32 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
Dear folks!
I compiled successfully a code ported from gcc/linux that runs OK there. However, I'm getting stack underflow error when running it under Plan 9.
The code is here:
http://www.gli.cas.cz/home/cejchan/plan9/pathd8.tgz
to run:
pathd8 infile outfile
Any hints much appreciated!! I cant't see why zeros are read in within the second cycle [see print()]
Thanks, regards,
++pac.
[-- Attachment #2: Type: text/html, Size: 3683 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] debugging help asked for
2007-05-21 11:32 [9fans] debugging help asked for cej
@ 2007-05-21 13:36 ` Richard Miller
2007-05-22 10:43 ` Charles Forsyth
1 sibling, 0 replies; 5+ messages in thread
From: Richard Miller @ 2007-05-21 13:36 UTC (permalink / raw)
To: 9fans
You're dividing by zero in pathd8/mpl.c:
subtree_var[i] = n->child[i]->var + n->edge_len[i];
...
p_bar_numerator += subtree_est[i]/subtree_var[i];
because the terminal node 'Frog' has var and edge_len
both equal to zero.
Possibly gcc/linux reacts differently to division by zero?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] debugging help asked for
2007-05-21 11:32 [9fans] debugging help asked for cej
2007-05-21 13:36 ` Richard Miller
@ 2007-05-22 10:43 ` Charles Forsyth
2007-05-22 10:45 ` Charles Forsyth
1 sibling, 1 reply; 5+ messages in thread
From: Charles Forsyth @ 2007-05-22 10:43 UTC (permalink / raw)
To: 9fans
> I compiled successfully a code ported from gcc/linux that runs OK there. However, I'm getting stack underflow error when running it under Plan 9.
that often happens when a function that returns double has no external declaration in scope where it's used,
and it gets the default type of int, so the result on the floating-point stack is not popped at the point of call.
that applies even when it's called for side-effect.
double f(int);
void
g(void)
{
f(3);
}
h% 8c -S db.c
TEXT g+0(SB),0,$8
MOVL $3,AX
MOVL AX,(SP)
CALL ,f+0(SB)
FMOVDP F0,F0
RET ,
END ,
note the P (pop) suffix on FMOVDP
of course, the compiler will have complained about the missing
declaration unless you've told it otherwise.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] debugging help asked for
2007-05-22 10:43 ` Charles Forsyth
@ 2007-05-22 10:45 ` Charles Forsyth
2007-05-22 11:03 ` Charles Forsyth
0 siblings, 1 reply; 5+ messages in thread
From: Charles Forsyth @ 2007-05-22 10:45 UTC (permalink / raw)
To: 9fans
>> I compiled successfully a code ported from gcc/linux that runs OK there. However, I'm getting stack underflow error when running it under Plan 9.
>
> that often happens when a function that returns double has no external declaration in scope where it's used,
hang on: perhaps that only causes stack overflow. oh well, now you know not to do it in any case.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] debugging help asked for
2007-05-22 10:45 ` Charles Forsyth
@ 2007-05-22 11:03 ` Charles Forsyth
0 siblings, 0 replies; 5+ messages in thread
From: Charles Forsyth @ 2007-05-22 11:03 UTC (permalink / raw)
To: 9fans
>> that often happens when a function that returns double has no external declaration in scope where it's used,
>
> hang on: perhaps that only causes stack overflow. oh well, now you know not to do it in any case.
i've checked now: that case does give stack overflow.
stack underflow will result if you declare a function as returning double in the caller, but it doesn't actually do that,
perhaps it's void or int.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-05-22 11:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-21 11:32 [9fans] debugging help asked for cej
2007-05-21 13:36 ` Richard Miller
2007-05-22 10:43 ` Charles Forsyth
2007-05-22 10:45 ` Charles Forsyth
2007-05-22 11:03 ` Charles Forsyth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).