Welcome, Guest. Please login or register.

Author Topic: Weird, C string. Crashes on m68k, works on MOS  (Read 13267 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline psxphill

Re: Weird, C string. Crashes on m68k, works on MOS
« on: May 28, 2017, 09:16:18 AM »
Quote from: asrael22;826231
I could partly narrow it down to allocating dynamic memory instead of using stack data.

It's likely that you've got a buffer overrun and you've changed from corrupting the stack to corrupting the heap & it just happens that it can tolerate the heap becoming corrupt.

You need to put it back so that it crashes and then dismantle the program so that it does less until it stops crashing. There are times when I've not been able to spot my dumb mistakes, so I just throw away the code and start again.

In the 90's I knew someone who went days trying to figure out why he was getting corrupt memory and in the end he had mixed up some strcmp and strcpy calls.
 

Offline psxphill

Re: Weird, C string. Crashes on m68k, works on MOS
« Reply #1 on: June 01, 2017, 02:51:58 PM »
Quote from: asrael22;826535
Code: [Select]
char hexOut[len*2+1];

It looks like a compiler bug. One of the compilers I have to support didn't work with variable length arrays until very recently, I still avoid them.

I never used vbcc, I always stuck to gcc 2.95 and sas/c. But vbcc is still supported, so you may be able to get it fixed. It's a pity there isn't a modern gcc or clang build targeting 68k.

"Please support vbcc by contacting the authors if you find any bugs or problems. Supporting eight different architectures makes testing extremely time consuming, so this release is probably not free of bugs.

For problems with the compiler core contact Dr. Volker Barthelmann (vbemail), and for Amiga/Atari-specific problems, including assembler, linker, startup-codes and linker-libraries, contact Frank Wille (fwemail)."