daphne-project / daphne-project/daphne
[Bug] Segmentation Fault after ReadFrame from UDF parameter
- Dominant language
- C++
- Stars
- 81
- Forks
- 83
- PR merge metrics
- No merged PRs in 30d
Description
Hi, still a problem from readFrame from function parameter.
## This does not work with `Segmentation fault (core dumped)`
```cpp
import "libutils.daphne";
DATA_PATH = "data/PCF1_tdms_group_0_head.csv";
power = libutils.readPowerFromCycle(DATA_PATH);
//print(power);
time_step = 0.000004;
time = seq(0, time_step*(nrow(power) - 1), time_step);
```
Adding the commented `print(power);` statement and it works ...
### UDF
```cpp
def readPowerFromCycle(path: str) {
group_data = readFrame(path);
power = as.matrix(group_data[,"Id"]) * as.matrix(group_data[,"Vds"]);
power = abs(power); // power is always positive
return power;
}
```
Here I also encounter the problem that I can't define the return type: `def readPowerFromCycle(path: str) -> matrix{` leads to `[error]: Parser error: Function 'readPowerFromCycle' returns different type than specified in the definition`
### This works
```cpp
DATA_PATH = "data/PCF1_tdms_group_0_head.csv";
group_data = readFrame(DATA_PATH);
power = as.matrix(group_data[,"Id"]) * as.matrix(group_data[,"Vds"]);
power = abs(power); // power is always positive
time_step = 0.000004;
time = seq(0, time_step*(nrow(power) - 1), time_step);
```
## Also
```cpp
import "libutils.daphne";
DATA_PATH = "data/PCF1_tdms_group_0_head.csv";
power = libutils.readPowerFromCycle(DATA_PATH);
time_step = 0.000004;
time = time_step*(nrow(power)) - 1;
//print(time);
```
works, but adding the `print(time);` statement, again segmentation fault.
Contributor guide
Research direction
Start by running the supplied DAPHNE scripts with readPowerFromCycle, readFrame, print, and seq to reproduce both segmentation faults and the declared-return-type error. Trace UDF parameter handling and the readFrame/print execution paths; done means these examples run without a segmentation fault and the matrix return annotation is accepted consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100