<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Tablegen segmentation fault when using foreach loop + sequence for pattern matching"
   href="https://bugs.llvm.org/show_bug.cgi?id=46708">46708</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Tablegen segmentation fault when using foreach loop + sequence for pattern matching
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>TableGen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aidanrbwood@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23724" name="attach_23724" title="the file containing the code that caused the segfault">attachment 23724</a> <a href="attachment.cgi?id=23724&action=edit" title="the file containing the code that caused the segfault">[details]</a></span>
the file containing the code that caused the segfault

Hi,

I'm currently writing a backend for a VLIW-like processor for my fourth year
design project. I was messing around with Tablegen trying to using foreach
loops to generate all of my numbered register as well as using sequences to
match those registers into RegisterClasses. I tried parsing the input with
table gen and the program segfaulted and requested I file a bug so here I am.

Below is the stack output of tablegen upon the seg fault occurring:

Included from fwipSchedule.td:8:                                                
  2 fwipRegisterInfo.td:62:12: error: Unknown token when parsing a value        
  3     def FU#in : FWIPStatReg<4,i,1,"n">;                                     
  4            ^                                                                
  5  #0 0x00005627f420c96e llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/arbwood/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:568:3
  6  #1 0x00005627f420a9e4 llvm::sys::RunSignalHandlers()
/home/arbwood/llvm/llvm-project/llvm/lib/Support/Signals.cpp:68:20            
  7  #2 0x00005627f420b035 SignalHandler(int)
/home/arbwood/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:396:31        
  8  #3 0x00007f4b2bb323c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)                                 
  9  #4 0x00005627f42473c8 llvm::TypedInit::classof(llvm::Init const*)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/TableGen/Record.h:437:46
 10  #5 0x00005627f42473c8 llvm::isa_impl<llvm::TypedInit, llvm::Init,
void>::doit(llvm::Init const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:58:23
 11  #6 0x00005627f42473c8 llvm::isa_impl_cl<llvm::TypedInit, llvm::Init
const*>::doit(llvm::Init const*)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:105:36
 12  #7 0x00005627f42473c8 llvm::isa_impl_wrap<llvm::TypedInit, llvm::Init
const*, llvm::Init const*>::doit(llvm::Init const* const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:131:40
 13  #8 0x00005627f42473c8 llvm::isa_impl_wrap<llvm::TypedInit, llvm::Init*
const, llvm::Init const*>::doit(llvm::Init* const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:122:60
 14  #9 0x00005627f42473c8 bool llvm::isa<llvm::TypedInit,
llvm::Init*>(llvm::Init* const&)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:142:74
 15 #10 0x00005627f42473c8 llvm::cast_retty<llvm::TypedInit,
llvm::Init*>::ret_type llvm::dyn_cast<llvm::TypedInit, llvm::Init>(llvm::Init*)
/home/arbwood/llvm/llvm-project/llvm/include/llvm/Support/Casting.h:339:16
 16 #11 0x00005627f42473c8 llvm::TGParser::ParseValue(llvm::Record*,
llvm::RecTy*, llvm::TGParser::IDParseMode) (.localalias)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:2242:34
 17 #12 0x00005627f424c187 llvm::TGParser::ParseObjectName(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:522:26
 18 #13 0x00005627f424c187 llvm::TGParser::ParseObjectName(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:505:7
 19 #14 0x00005627f424e225 llvm::TGParser::ParseDef(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:2708:3
 20 #15 0x00005627f424f16d llvm::TGParser::ParseObject(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3329:40
 21 #16 0x00005627f424f981 llvm::TGParser::ParseObjectList(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3356:5
 22 #17 0x00005627f4250690 llvm::TGParser::ParseForeach(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:2844:5
 23 #18 0x00005627f424f175 llvm::TGParser::ParseObject(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3330:48
 24 #19 0x00005627f424f981 llvm::TGParser::ParseObjectList(llvm::MultiClass*)
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3356:5
 25 #20 0x00005627f424fffc llvm::TGParser::ParseFile()
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/TGParser.cpp:3364:3           
 26 #21 0x00005627f4216a02 llvm::TableGenMain(char const*, bool
(*)(llvm::raw_ostream&, llvm::RecordKeeper&))
/home/arbwood/llvm/llvm-project/llvm/lib/TableGen/Main.cpp:102:3
 27 #22 0x00005627f3fd991a main
/home/arbwood/llvm/llvm-project/llvm/utils/TableGen/TableGen.cpp:269:22         
 28 #23 0x00007f4b2b5d70b3 __libc_start_main
/build/glibc-YYA7BZ/glibc-2.31/csu/../csu/libc-start.c:342:3                    
 29 #24 0x00005627f3fdc70e _start
(/home/arbwood/llvm/obj/bin/llvm-tblgen+0x1770e)                                
 30 PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.                                               
 31 Stack dump:                                                                 
 32 0.      Program arguments: /home/arbwood/llvm/obj/bin/llvm-tblgen
fwipSchedule.td                                                   
 33 Segmentation fault (core dumped)

Attached is the file fwipRegisterInfo.tb which contained the offending code,
let me know if you have any questions/require additional info.

Thanks!</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>