my c program crashes on 16.04, but not on 14.04
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux-hwe (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#define BUF_ROWS 100
#define BUF_COLS 64
/*@
* this demo code can run on ubuntu 14.04 (32bit & 64bit) and mac osx (64bit)
* But NOT on ubuntu 16.04 (64bit) as tested !
*/
#define dbg(...) fprintf(
void split_r(char* str, char* delim, char* toks[], size_t* sz)
{
char* x, *sp;
int i;
x = strtok_r(str, delim, &sp);
i = 0;
while (x) {
toks[i] = malloc(
i++;
x = strtok_r(NULL, delim, &sp);
}
*sz = i;
}
int main(int argc, char** argv) {
int gCnt, done =0;
char ibuf[4096];
char delim[] = " ";
char* toks[8] = {NULL};
size_t n;
char** in;
FILE* fp=fopen(
if(!fp) { fprintf(
while(!done) {
gCnt=0;
in = malloc(BUF_ROWS * BUF_COLS * sizeof(char*) );
while (gCnt < BUF_ROWS*BUF_COLS) {
if( n != 4) {
}
} else {
}
}
pid_t pid;
// do sth
exit(0);
}
wait(NULL);
for (int i=0; i<gCnt; i++)
for(int i=0; i< BUF_ROWS * BUF_COLS; i++) free(in[i]);
free(in);
} // end of done
}
This program takes a input file in which each line has 4 tokens (strings). When I run it with a input file that contains 10000 lines, it always chokes at somewhere about 5000 ~ 6000th line in the input file on ubuntu 16.04. But it never chokes on ubuntu 14.04 & macbook pro -10.12.5. the input file contains the data something like that below ( each line has 4 strings only )
1 + 1 = 2
2 * 2 = 4
4 - 1 = 3
6 / 3 = 2
etc...
please let me know if any more information needed via my email
<email address hidden>
Thank you for attentions !!!
Best Regards
MJ
ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: linux-image-
ProcVersionSign
Uname: Linux 4.10.0-37-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.10
Architecture: amd64
CurrentDesktop: GNOME-Flashback
Date: Sat Oct 28 21:24:13 2017
InstallationDate: Installed on 2016-01-11 (656 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Release amd64 (20140417)
SourcePackage: linux-hwe
UpgradeStatus: No upgrade log present (probably fresh install)
Hello,
It not seems a security issue so I'm changing this to public.
It's probably related with the compile version and ABI between those releases.