Skip to content

Exception thrown when parsing the header file in Microsoft SDK #46

Open

Description

@ShadowLL
typedef enum _WSACOMPLETIONTYPE {
    NSP_NOTIFY_IMMEDIATELY = 0,
    NSP_NOTIFY_HWND,
    NSP_NOTIFY_EVENT,
    NSP_NOTIFY_PORT,
    NSP_NOTIFY_APC,
} WSACOMPLETIONTYPE, *PWSACOMPLETIONTYPE, FAR * LPWSACOMPLETIONTYPE;

This is detailed exception information:

Connected to pydev debugger (build 192.6262.63)
Traceback (most recent call last):
  File "/home/fuzz/.virtualenvs/pypy_xfuzz/site-packages/CppHeaderParser/CppHeaderParser.py", line 2913, in __init__
    self._evaluate_stack()
  File "/home/fuzz/.virtualenvs/pypy_xfuzz/site-packages/CppHeaderParser/CppHeaderParser.py", line 3343, in _evaluate_stack
    self._parse_enum()
  File "/home/fuzz/.virtualenvs/pypy_xfuzz/site-packages/CppHeaderParser/CppHeaderParser.py", line 3536, in _parse_enum
    self._next_token_must_be(";")
  File "/home/fuzz/.virtualenvs/pypy_xfuzz/site-packages/CppHeaderParser/CppHeaderParser.py", line 3113, in _next_token_must_be
    raise self._parse_error((tok,), "' or '".join(tokenTypes))
CppHeaderParser.CppHeaderParser.CppParseError: unexpected ',', expected ';'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/fuzz/app/pycharm-2019.2.1/helpers/pydev/pydevd.py", line 2060, in <module>
    main()
  File "/home/fuzz/app/pycharm-2019.2.1/helpers/pydev/pydevd.py", line 2054, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/fuzz/app/pycharm-2019.2.1/helpers/pydev/pydevd.py", line 1405, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "/home/fuzz/app/pycharm-2019.2.1/helpers/pydev/pydevd.py", line 1412, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/fuzz/app/pycharm-2019.2.1/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/fuzz/workspace/xfuzz/database/src_code_analysis/analysis.py", line 3, in <module>
    header = CppHeaderParser.CppHeader('/home/fuzz/workspace/xfuzz/database/windos_sdk_hfs/Include/WinSock2.h')
  File "/home/fuzz/.virtualenvs/pypy_xfuzz/site-packages/CppHeaderParser/CppHeaderParser.py", line 3048, in __init__
    CppParseError(msg), e,
  File "<string>", line 1, in raise_exc
CppHeaderParser.CppHeaderParser.CppParseError: Not able to parse /home/fuzz/workspace/xfuzz/database/windos_sdk_hfs/Include/WinSock2.h on line 1074 evaluating ',': unexpected ',', expected ';'
Error around: typedef enum _WSACOMPLETIONTYPE

Activity

  1. virtuald commented on Apr 9, 2020

    @virtuald
    Member

    Definitely a bug. I don't really have an interest in fixing this myself (lots of stuff going on), but I can provide guidance for debugging/fixing this if you would like to fix it and make a PR.

    In particular, I find that setting the environment variable CPPHEADERPARSER_DEBUG=1 is really useful for figuring out what the parser is doing.

    I imagine that this isn't the only piece in the SDK that would cause problems. Might try just commenting out that enum and see what else breaks.

  2. liuyongbao1982 commented on Jan 11, 2022

    @liuyongbao1982

    The following code has the same parsing error: evaluating '': unexpected '', expected ';'
    struct AudioPortCapability {
    enum AudioFormat* formats; /**< Supported audio formats. For details, see {@link AudioFormat}. */
    };


    After I modified the following code, the program can run normally:
    def _parse_enum(self):
    ......
    # TODO: nested_name_specifier
    name = ""
    if nametok.type == "NAME":
    name = nametok.value
    debug_print("enum name is '%s'", name)
    tok = self.lex.token()
    #MODIFED:
    if tok.value == "*":
    name = name + ' *'
    tok = self.lex.token()
    else:
    debug_print("anonymous enum")
    tok = nametok

  3. auscompgeek commented on Jan 11, 2022

    @auscompgeek
    Member

    @liuyongbao1982 That looks like a different parse error to me. If you open a PR though with your change and a test, we'd be happy to take your change, since that's also a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions