https://bugs.kde.org/show_bug.cgi?id=513285
Bug ID: 513285
Summary: big malloc() causes: Valgrind received a signal 11
(SIGSEGV) - exiting
Classification: Developer tools
Product: valgrind
Version First 3.26.0
Reported In:
Platform: unspecified
OS: Unspecified
Status: REPORTED
Severity: crash
Priority: NOR
Component: general
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 187576
--> https://bugs.kde.org/attachment.cgi?id=187576&action=edit
Output from valgrind -v
SYSTEM INFORMATION
host- and username changed
uname -a
Linux hostname 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1
(2025-11-09) x86_64 GNU/Linux
Valgrind output in the attachment.
STEPS TO REPRODUCE
this is the bugged c code that causes valgrind to segfault.
tested with
gcc (Debian 12.2.0-14+deb12u1) 12.2.0
and
Debian clang version 14.0.6
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
double re;
double im;
} complex;
FILE *file, *output;
long long k, samplerate, amount;
char line[512];
char *buffer = 0;
long length;
int main(int argc, char **argv) {
file = fopen(argv[1], "rb");
if (file == NULL) {
fprintf(stderr, "Opening file \n");
return -1;
};
fscanf(file, "%s", line);
samplerate = atoi(line);
fscanf(file, "%s", line);
amount = atoi(line);
fprintf(stderr, "%lld \n", amount);
complex *v = (complex *)malloc(amount * sizeof(real));
complex *scratch = (complex *)malloc(amount * sizeof(double));
fprintf(stderr, "%lld\n", amount);
// Broken thing
while (fscanf(file, "%s", line) != EOF) {
v[k].re = atof(line);
v[k].im = 0;
k++;
}
fprintf(stderr, "test");
fclose(file);
long msb = 0;
while (amount != 0) {
amount = amount / 2;
msb++;
}
long long bytething;
bytething = 1 << msb;
printf("%lld\n", bytething);
}
The amount variable read from the file is 481489 and there is that many lines
with numbers after that.
--
You are receiving this mail because:
You are watching all bug changes.