Crashing on port as parameter in interface call
Posted: Wed Feb 21, 2018 1:50 pm
				
				This code crashes when i_my.x_crashes is called. The original SW instead uses p_spi_aux_in_call in i_my.y (not shown here), which works.
I didn't think it would be illegal to send a port along in an interface call?
Another thing, if I only call i_my.y (); the stack size calculation fails!?
			I didn't think it would be illegal to send a port along in an interface call?
Another thing, if I only call i_my.y (); the stack size calculation fails!?
Code: Select all
#include <platform.h>
#include <xs1.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <iso646.h>
#include <xccompat.h> // REFERENCE_PARAMs
typedef enum {false,true} bool;
typedef interface my_if {
    void x_crashes (out port p_spi_aux_in_call);
    void y (void);
} my_if;
[[combinable]]
void my_client (client my_if i_my, out port p_spi_aux_in_call) {
    timer    tmr;
    unsigned current_time;
    bool     now = true;
    tmr :> current_time;
    while (1) {
        select {
            case tmr when timerafter(current_time) :> void: {
                current_time += XS1_TIMER_HZ; // Once per second
                if (now) {
                    i_my.y (); // This first run always succeeds
                } else {
                    // i_my.y (); // If only this here, it's confused as to stack size calculations:
                    // ../src/main.xc:(.dp.data+0x4): Error: Meta information ("my_client.nstackwords") for function "my_client" cannot be determined.
                    // ../src/main.xc:(.dp.data+0x4): Error:   lower bound could not be calculated (function is recursive?)
                    
                    i_my.x_crashes (p_spi_aux_in_call);
                    // tile[0] core[1]  (Suspended: Signal 'ET_ILLEGAL_RESOURCE' received. Description: Resource exception.)   
                    //    3 my_server() main.xc:646 0x0001021e    
                    //    2 __main__main_tile_0_combined_tile_0_u0() main.xc:664 0x00010298   
                    //    1 __start_core()  0x00010b72    
                }
                now = not now;
            } break;
        }
    }
}
[[combinable]]
void my_server (server my_if i_my, out port p_spi_aux_in_init) {
    while (1) {
        select {
            case i_my.x_crashes (out port p_spi_aux_in_call): {
                printf("i_my.x crashes in line above\n"); // So never gets here
                break;
            }
            case i_my.y (void): {
                printf("i_my.y here\n");
                break;
            }
        }
    }
}
out port p_spi_aux_in_init = XS1_PORT_4C;
out port p_spi_aux_in_call = XS1_PORT_4D;
int main() {
    my_if i_my;
    par {
        on tile[0].core[0]: my_server (i_my, p_spi_aux_in_init);
        on tile[0].core[1]: my_client (i_my, p_spi_aux_in_call);
    }
    return 0;
}