Author Topic: printf() bug?  (Read 514 times)

Offline rudolf128

  • Multiple posting newcomer
  • *
  • Posts: 29
printf() bug?
« on: February 07, 2019, 06:01:39 am »
Due to previous problems, I compiled my program without optimization. After running for a few seconds, it failed with SEGMENTATION FAULT. The point of failure was a printf call, which ran without problem for some seconds before. Please see a sample of the output:
N#3043 THREAD#1 START#3402630 LENGTH#1996 R:A INDEX#3042 V=0.414683 WAVE:FADEINMAG
N#3044 THREAD#1 START#3402630 LENGTH#58528 R:V INDEX#3042 V=0.00672363 WAVE:SIN FR=21.3818 MOD:TREMOLO
N#3045 THREAD#1 START#3402630 LENGTH#58528 R:N V=0.138142 WAVE:BURST3 RING:MIN FR=103.826 PAN=0.0830693 SHAPE=0.400693 TRIM1=0.292253 TRIM2=-0.35383
N#3046 THREAD#1 START#3402630 LENGTH#1996 R:A INDEX#3045 V=0.414683 WAVE:FADEINMAG
N#3047 THREAD#1 START#3402630 LENGTH#58528 R:N V=0.138142 WAVE:BURST3 RING:MIN FR=103.826 PAN=0.0830693 SHAPE=0.400693 TRIM1=0.292253 TRIM2=-0.35383
N#3048 THREAD#1 START#3402630 LENGTH#58528 R:N V=0.138142 WAVE:BURST3 RING:MIN FR=103.826 PAN=0.0830693 SHAPE=0.400693 TRIM1=0.292253 TRIM2=-0.35383
N#3049 THREAD#1 START#3402630 LENGTH#58528 R:N V=0.138142 WAVE:BURST3 RING:MIN FR=103.826 PAN=0.0830693 SHAPE=0.400693 TRIM1=0.292253 TRIM2=-0.35383
N#3050 THREAD#1 START#3402630 LENGTH#58528 R:N V=0.1381

The fragment of code with the problem (please see attachment)

The stats() routine:
void stats(void)
// Prepare usage statistics
{
  if (Par.p[SAMPLE] != 2) // Generate usage statistics
    Tabring[Par.smt].use++;
  if (Par.mt >= 0)
    Tabmod[Par.mt + 1].use++;
  Tabmain[Par.id].use++;
}

The disassemble at the point marked (please see attachment)

Offline rudolf128

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: printf() bug?
« Reply #1 on: February 07, 2019, 06:10:13 am »
Please notice that this happens only when using Debug (F8), not when merely running the program.
But anyway, if any other error appears, I need debugging to work.

Online stahta01

  • Lives here!
  • ****
  • Posts: 6553
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2379
Re: printf() bug?
« Reply #3 on: February 07, 2019, 07:56:26 pm »
If your app crashes Codeblocks has no influence in that (or does codeblocks crash?)
You probably have some race conditions or write on memory you are not allowed... Intense debugging helps. If it does work with optimized it does not mean there is no bug on your side ;). But it can also be a bug in the compiler. Anyway, as long as codeblocks does not crash this is not the right forum to get help, as stahta01 points out...


Offline rudolf128

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: printf() bug?
« Reply #4 on: February 07, 2019, 10:12:59 pm »
OK, I understand. Thank you. Where do you think I will get some help on this subject?