Jump to content

Bug: Stack Overflow When Using Function Pointers


Recommended Posts

Bug description:

-------------------

The -swcs option does not work correctly together with function pointers.

The call tree is not parsed correctly together with function pointers.

 

With "-swcs 0 1" the following code compiles correctly. With"-swcs 2 1" the compiler uses the hardware stack for both, the call to __fptr and the calls of fptr0..4(). This results in a stack overflow during the call of fptr4().

 

Steps to reproduce:

-----------------------

 

#include <system.h>

 

void (*fptr0)();

void (*fptr1)();

void (*fptr2)();

void (*fptr3)();

void (*fptr4)();

 

void test4() {

}

void test3() {

fptr4();

}

void test2() {

fptr3();

}

void test1() {

fptr2();

}

 

void test0() {

fptr1();

}

 

void main() {

fptr0 = test0;

fptr1 = test1;

fptr2 = test2;

fptr3 = test3;

fptr4 = test4;

 

fptr0();

 

while(1);

}

 

 

Expected behaviour:

The program should not produce a stack overflow.

 

Is the problem 100% reproduceable:

Yes.

 

IDE version: 6.81

Compiler: BoostC,

Compiler version: boostc.pic16.exe / v6.81

Target device: PIC16F88

OS: WinXP

 

Comments:

It seems that the call tree is not parsed through the __fptr function. If this is true, function pointers should be only compiled with "-swcs 0 1" or "-swcs 1 1" unless their use is very limited and the programmer takes care about stack overflows.

 

BR

manuel123

Link to post
Share on other sites
  • 1 month later...

manuel123,

Bug description:

-------------------

The -swcs option does not work correctly together with function pointers.

The call tree is not parsed correctly together with function pointers.

This has been fixed and will be in the next release.

 

Regards

Dave

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...