0

my problem is i have a program that runs on Windows perfectly while on Dev machine it gives segmentation fault without any output from my program.To test it ,i put a printf() at the start of main ,before any code piece and it still gave segmentaion fault without printing anything.

#0 0x00007f374105adc0 in __strcpy_sse2 () from /lib64/libc.so.6

Only line is understandable by me is above bolded line.I did not want to bloat page with my whole code .So if you can give me a direction or ask for specific lines,i will be ready here.

Edit:Added meaningful backtrace,removed some mumbo jumbo. I investigated debugging a bit more and reached these info;

0 0x00007f6da93f2dc0 in __strcpy_sse2 () from /lib64/libc.so.6

1 0x00000000004017e5 in read_customer_info ()

2 0x0000000000401756 in read_customers ()

3 0x0000000000401289 in operate ()

4 0x0000000000401a64 in main ()

code piece in the innermost function ;

char *name;
name = (char*)malloc(15*sizeof(char));
int transaction_amount;
int transaction_time;

coming_minute=atoi(strtok(temp_line,",\0"));
strcpy(name,strtok(NULL,",\0"));

I can see using strtok as argument of strcpy might cause this segfault.Should i use temporary char pointer instead of directly using the one from strtok() return value?

0 Answers0