[9fans] debugging help asked for - Plan9

This is a discussion on [9fans] debugging help asked for - Plan9 ; 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!! ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: [9fans] debugging help asked for

  1. [9fans] debugging help asked for

    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.





  2. Re: [9fans] debugging help asked for

    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?


  3. Re: [9fans] debugging help asked for

    > 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.


  4. Re: [9fans] debugging help asked for

    >> 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.


  5. Re: [9fans] debugging help asked for

    >> 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.


+ Reply to Thread