FlexLexer.h

47 views
Skip to first unread message

Jeff Bush

unread,
Jun 1, 2015, 12:27:41 PM6/1/15
to mcli...@googlegroups.com
FlexLexer.h is checked into the mclinker tree at include/mcld/Script/FlexLexer.h.  Is there a reason for this?  This is a system header that is paired with the installed version of flex.  

I'm running into a crash that occurs because some files include the system FlexLexer.h and others use the version checked into the mclinker tree. Because the structure layout differs between the two on my system, this clobbers memory.  If I remove the FlexLexer.h from the mclinker tree, everything compiles and runs fine.

--Jeff

Pete Chou

unread,
Jun 1, 2015, 11:31:13 PM6/1/15
to Jeff Bush, mcli...@googlegroups.com
Hi,

Would you please let us know you system environment like OS and Flex version?

If I recall correctly, I think this is to work around the compilation on MAC because the flex on MAC is patched. 

Thanks,
Pete

--
You received this message because you are subscribed to the Google Groups "MCLinker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mclinker+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Bush

unread,
Jun 2, 2015, 12:02:31 AM6/2/15
to mcli...@googlegroups.com, jeffb...@gmail.com


On Monday, June 1, 2015 at 8:31:13 PM UTC-7, pete chou wrote:
Hi,

Would you please let us know you system environment like OS and Flex version?

If I recall correctly, I think this is to work around the compilation on MAC because the flex on MAC is patched. 

I'm on OSX Yosemite.  Using the default version of flex provided by Apple (2.5.35)

The problem is that your version of FlexLexer.h defines yy_n_chars as int (32 bits):

int yy_n_chars;
  
The system version defines it as size_t, which is 64 bits on Mac:

size_t yy_n_chars;

The two structure definitions have different sizes and member alignments. It appears when ScriptReader is compiled, it uses the mclinker version of the header. It allocates a member on the stack in readScript. It then calls into the constructor (in the generated file ScriptScanner.cpp), which seems to have included the system version of the header. The latter assumes a larger structure, writing past the size allocated on the stack for the structure and smashing the stack. It crashes in __stack_chk_fail on return from readScript.


Pete Chou

unread,
Jun 2, 2015, 2:02:34 AM6/2/15
to Jeff Bush, mcli...@googlegroups.com
I think we can remove the local Flex header if we really don't need it on OSX.

Thanks,
Pete

Reply all
Reply to author
Forward
0 new messages