Jump to content

Getting Hard Faults when GDISP_NEED_TEXT_WORDWRAP is enabled


kengineer

Recommended Posts

It seems that I'm getting some hard faults upon setting GDISP_NEED_TEXT_WORDWRAP to true. I'm still working on figuring out the exact cause, but it appears it's when I do anything related to drawing labels, specifically in this function call:

 

static bool mf_countline_callback(mf_str line, uint16_t count, void *state) {
	int *linecount = (int*)state;
	(*linecount)++;

	return TRUE;
}

The fault specifically happens immediately after calling (*linecount)++;

 

Still looking into this but was wondering if anyone had any advice. FYI I'm using uGFX v2.4

Link to comment
Share on other sites

I think I figured it out, there's a bug here.

In mf_countline_callback, you are casting the void pointer as an int type which technically would vary by platform (int32_t on my platform).

 

IF you go up a couple of function calls, you'll find:

mf_wordwrap(font, cx, str, mf_countline_callback, &nbrLines);

Where nbrLines is defined as a uint16_t.

This is the problem, you're passing a uint16_t pointer in this case, and casting it as a 32 (at least on this platform) resulting in not incrementing the same part of memory we think we are. Upon modifying this, I don't get a hard fault anymore, so I'm going to see if the text wrap actually works now. Please verify this and move to the bug reports area.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...