Giter Site home page Giter Site logo

Comments (9)

poweihuang17 avatar poweihuang17 commented on July 26, 2024

I got the same problem with this code. Does anyone has some idea about what to deal with this now.
1 #define M 1000
2 #define N 2000
3 #include <stdio.h>
4 int main(){
5 int sum;
6 int a[M][N];
7 for (int i=0;i<M;i++)
8 for (int j=0;j<N;j++)
9 a[i][j]=i+j;
10 printf("Matrix\n");
11 }

from riscv-pk.

kito-cheng avatar kito-cheng commented on July 26, 2024

@nakengelhardt Can you provide a testcase?

@poweihuang17 pk set stack size to 256k [1], and you program require 1000 * 2000 * sizeof (int) = 16M, so your case is stack overflow.

[1] https://github.com/riscv/riscv-pk/blob/master/pk/mmap.c#L404

from riscv-pk.

nakengelhardt avatar nakengelhardt commented on July 26, 2024

Oh right. It's the stack for me too, the multiply function made a copy of the two input matrices to the stack for some reason.

from riscv-pk.

poweihuang17 avatar poweihuang17 commented on July 26, 2024

@kito-cheng Thanks for your reply. But that setting (256K) will make pk pretty limited. I will try to use spike to run my program in bare-metal mode without pk now. However, I'm wondering why does people set such a small stack for pk? Isn't that a problem that we should modify?

from riscv-pk.

kito-cheng avatar kito-cheng commented on July 26, 2024

@aswaterman How about increase stack size to 8M in pk just like x86/linux default?

from riscv-pk.

aswaterman avatar aswaterman commented on July 26, 2024

pk also runs on systems with very limited RAM, so 8 MiB is too large. I guess we can give it something like 3% of memory, up to a max of 8 MiB.

from riscv-pk.

aswaterman avatar aswaterman commented on July 26, 2024

0f0ac64

from riscv-pk.

theotuck avatar theotuck commented on July 26, 2024

even increasing the stack size, there is constantly user load segfault for me.
for doing my own test, I even modify the stack size to 32768*RISCV_PGSIZE, but it doesn't work.

Here is my command line:
root@osboxes:/home/osboxes/mycode/V7/router-trie/poptrie-master# spike pk poptrie_test_basic

the output:

init: .passed
lookup: start the poptrie_fib_ret
z 0000000000000000 ra 0000000000014154 sp 000000007ffffa70 gp 000000000002c8c0 tp 0000000000000000 t0 0000000000017e10 t1 000000007ffff920 t2 0000000000000000 s0 000000007ffffaa0 s1 0000000000000000 a0 0000000000000013 a1 000000007ffff91c a2 000000000002c283 a3 0000000000000400 a4 00000000028bc890 a5 00000000028c5000 a6 8080808080808080 a7 fefefefefefefeff s2 0000000000000000 s3 0000000000000000 s4 0000000000000000 s5 0000000000000000 s6 0000000000000000 s7 0000000000000000 s8 0000000000000000 s9 0000000000000000 sA 0000000000000000 sB 0000000000000000 t3 fffffffffffffffb t4 0000000000000000 t5 0000000000000000 t6 0000000000000000 pc 0000000000014168 va 00000000028c5000 insn ffffffff sr 8000000000006000 User load segfault @ 0x00000000028c5000

and the disassembler:

14160: fec42783 lw a5,-20(s0) 14164: 0792 slli a5,a5,0x4 14166: 97ba add a5,a5,a4 14168: 639c ld a5,0(a5) 1416a: fd043703 ld a4,-48(s0) 1416e: 02f71263 bne a4,a5,14192 <poptrie_fib_ref+0x62>

from riscv-pk.

poweihuang17 avatar poweihuang17 commented on July 26, 2024

@theotuck Could you upload your code so that we could debug? It's really hard to debug without the understanding of your testcase?

from riscv-pk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.