summary refs log tree commit diff stats
path: root/gitlab/issues/target_riscv/host_missing/accel_missing/2223.toml
blob: 72f1b94707e8fff57be484963c40380804046ff3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
id = 2223
title = "Weird behavior on RISC-V code running on QEMU"
state = "closed"
created_at = "2024-03-14T05:10:09.064Z"
closed_at = "2024-04-04T16:31:59.985Z"
labels = ["target: riscv"]
url = "https://gitlab.com/qemu-project/qemu/-/issues/2223"
host-os = "Zorin OS 16.3 (based on Ubuntu 22.04)"
host-arch = "x86"
qemu-version = "qemu-system-riscv32"
guest-os = "none"
guest-arch = "RISC-V"
description = """I am currently facing some weird problems on a RISC-V project meant to run on the QEMU environment and thought that maybe someone here could give me a light on the subject. The goal is to run a project built on top of one of FreeRTOS' official demo ports that target the 'virt' QEMU board. I ran across a few weird behaviors where code execution would just hang at some point (QEMU would keep execution but the expected terminal output would never come up). I don't have sufficient knowledge to tell whether the issue is with the FreeRTOS port, the RISC-V gnu toolchain or QEMU itself, hence why I am raising my hand for help on all related channels.

This [repository](https://bitbucket.org/softcps-investigacao-risc-v/freertos-riscv-bugs/src/master/) contains more details and a sample project that illustrates well one of the problems I've been getting lately (I also give more context about it [here](https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1434)). It basically goes like this: the program **executes fine** when a certain code snippet is encapsulated **within a function**, but "**crashes**" (i.e. hangs) when the same snippet is placed **directly in the main code**:

```c
for(int i=0; i < NUMBER_OF_ITEMS; i++){
    createAndPushItem(i);

    // the function above does the exact same thing as the commented code below
    // yet, the commented code does not work and will crash the program. but why??
        
    // int index = priorities[i];                                               
    // void *value = (void *) getValue(i + 1);
    // LinkedListItem_t *item = createItem(index, value);                          
    // if(item){
    //     push(item, &list);
    // }
}
```

The scope shouldn't matter at all here, since there is no local variable being used or anything like that. I have tested workarounds like removing compiling optimization (i.e. changing -Os for -O0) and using regular malloc() instead of FreeRTOS' dynamic allocation API, but all without success.  Note that even though the project is build on top of the FreeRTOS demo port, no RTOS functionality is used within this code to make it as simple as it gets."""
reproduce = """1. clone this [repository](https://bitbucket.org/softcps-investigacao-risc-v/freertos-riscv-bugs/src/master/)
2. follow the readme to install the toolchain
3. follow the readme to compile the program and run it"""
additional = """The expected output is supposed to be:

![image](/uploads/462aa1a7872262df8f2588ee92dd5879/image.png)

but when one decides to use the commented snippet instead of the function, the program hangs right before sorting the linked list for the first time:

![image](/uploads/d2f7cc5614b293a5953e6fffa535aaca/image.png)"""