Closed joonazan closed 5 years ago
@johnkslang This did not really fix the issue.
This very similar looking code hangs.
int,i=
#define f g(#g(y
#define g(m)
g(f)
I fixed one problem and added one warning with the original submitted, and yes, likely there are more than two issues in the preprocessor with malformed arguments. Both fixes I did are valid and necessary in the general case.
My repro case was simplified from a larger fragment generated by fuzzing. The fixes you did happened to hide the crash present in the larger shader.
I'll see whether I can introduce the crash by hand in the fixed version if the fuzzer hasn't found it again by tomorrow.
I did actually fix a crash... it could be the same one you started with. Still, I consider a hang and a crash to have similar badness.
The problem with these examples is that the design uses a "marker" to delimit expansion, and for malformed input, that needs to be checked for in unusual places, where normally only end-of-input needs to be checked.
Your latest example works fine for me. I get:
ERROR: 0:4: 'macro expansion' : unexpected '#' g
ERROR: 0:4: 'macro expansion' : End of input in macro g
ERROR: 0:4: '' : compilation terminated
ERROR: 3 compilation errors. No code generated.
For the input
int,i=
#define f g(#g(y
#define g(m)
g(f)
Changing the #
to a !
, or .
, or removing it, I get:
ERROR: 0:4: 'macro expansion' : End of input in macro g
ERROR: 0:4: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
Is it possible I did fix this class of problems and you tested without my fix?
At commit 567396b6b40c08adc50d823d47755dc7612a1bfd, I get
WARNING: 0:1: '#define' : missing space after macro name
for my first finding. The second outputs nothing and does not terminate.
Same thing after pulling.
Under valgrind I get exactly the same output as you do, but with memory errors. I hope this helps.
==24077== Invalid read of size 8
==24077== at 0x41DB55: glslang::TPpContext::TokenStream::getSubtoken() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41DCEC: glslang::TPpContext::TokenStream::getToken(glslang::TParseContextBase&, glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41E1AD: glslang::TPpContext::tTokenInput::scan(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A12B0: glslang::TPpContext::scanToken(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41368E: glslang::TPpContext::MacroExpand(glslang::TPpToken*, bool, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0489: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== Address 0x5ec8910 is 32 bytes inside a block of size 40 free'd
==24077== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24077== by 0x414838: glslang::TPpContext::tMacroInput::~tMacroInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4148E5: glslang::TPpContext::tMacroInput::~tMacroInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x39AB38: glslang::TPpContext::popInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A12EB: glslang::TPpContext::scanToken(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0372: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== Block was alloc'd at
==24077== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24077== by 0x41359C: glslang::TPpContext::MacroExpand(glslang::TPpToken*, bool, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0489: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x34226F: (anonymous namespace)::CompileDeferred(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x342A0D: ShCompile (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x33447A: CompileFile(char const*, void*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077==
==24077== Invalid read of size 8
==24077== at 0x4152C2: std::vector<unsigned char, glslang::pool_allocator<unsigned char> >::size() const (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41DB64: glslang::TPpContext::TokenStream::getSubtoken() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41DCEC: glslang::TPpContext::TokenStream::getToken(glslang::TParseContextBase&, glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41E1AD: glslang::TPpContext::tTokenInput::scan(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A12B0: glslang::TPpContext::scanToken(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41368E: glslang::TPpContext::MacroExpand(glslang::TPpToken*, bool, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0489: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== Address 0x5ec8900 is 16 bytes inside a block of size 40 free'd
==24077== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24077== by 0x414838: glslang::TPpContext::tMacroInput::~tMacroInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4148E5: glslang::TPpContext::tMacroInput::~tMacroInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x39AB38: glslang::TPpContext::popInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A12EB: glslang::TPpContext::scanToken(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0372: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== Block was alloc'd at
==24077== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24077== by 0x41359C: glslang::TPpContext::MacroExpand(glslang::TPpToken*, bool, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0489: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x34226F: (anonymous namespace)::CompileDeferred(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x342A0D: ShCompile (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x33447A: CompileFile(char const*, void*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077==
==24077== Invalid read of size 8
==24077== at 0x4152CD: std::vector<unsigned char, glslang::pool_allocator<unsigned char> >::size() const (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41DB64: glslang::TPpContext::TokenStream::getSubtoken() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41DCEC: glslang::TPpContext::TokenStream::getToken(glslang::TParseContextBase&, glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41E1AD: glslang::TPpContext::tTokenInput::scan(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A12B0: glslang::TPpContext::scanToken(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x41368E: glslang::TPpContext::MacroExpand(glslang::TPpToken*, bool, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0489: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== Address 0x5ec88f8 is 8 bytes inside a block of size 40 free'd
==24077== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24077== by 0x414838: glslang::TPpContext::tMacroInput::~tMacroInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4148E5: glslang::TPpContext::tMacroInput::~tMacroInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x39AB38: glslang::TPpContext::popInput() (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A12EB: glslang::TPpContext::scanToken(glslang::TPpToken*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0372: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== Block was alloc'd at
==24077== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==24077== by 0x41359C: glslang::TPpContext::MacroExpand(glslang::TPpToken*, bool, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3A0489: glslang::TPpContext::tokenize(glslang::TPpToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x4089CA: glslang::TScanContext::tokenize(glslang::TPpContext*, glslang::TParserToken&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x404CE1: yylex(YYSTYPE*, glslang::TParseContext&) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x429935: yyparse(glslang::TParseContext*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x3D0E59: glslang::TParseContext::parseShaderStrings(glslang::TPpContext&, glslang::TInputScanner&, bool) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x341F22: (anonymous namespace)::DoFullParse::operator()(glslang::TParseContextBase&, glslang::TPpContext&, glslang::TInputScanner&, bool, glslang::TSymbolTable&, glslang::TIntermediate&, EShOptimizationLevel, EShMessages) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x346A05: bool (anonymous namespace)::ProcessDeferred<(anonymous namespace)::DoFullParse>(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, (anonymous namespace)::DoFullParse&, bool, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment const*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x34226F: (anonymous namespace)::CompileDeferred(TCompiler*, char const* const*, int, int const*, char const* const*, char const*, EShOptimizationLevel, TBuiltInResource const*, int, EProfile, bool, bool, EShMessages, glslang::TIntermediate&, glslang::TShader::Includer&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, glslang::TEnvironment*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x342A0D: ShCompile (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077== by 0x33447A: CompileFile(char const*, void*) (in /home/jsaarhelo/glslang/no_instr/StandAlone/glslangValidator)
==24077==
We must be looking at different examples. The last example you gave, which I tested, does have a space after the macro name. Can you post the source for your last post?
That warning was generated for the code in my first post. The memory errors are from the second code I posted:
int,i=
#define f g(#g(y
#define g(m)
g(f)
It depends on whether on not a newline is included at the end of the last line.
On my machine it hangs with or without newlines. But you managed to reproduce it now?
My machine reproduces it intermittently. But, now I fixed handling of a partially expanded argument that errors out in the middle of expansion.
glslangValidator -S vert file
segfaults iffile
contains the following.