Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • C cython
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Boxiang Sun
  • cython
  • Repository
  • cython
  • Cython
  • Utility
  • ImportExport.c
Find file BlameHistoryPermalink
  • Orivej Desh's avatar
    Fix calling va_arg function with a NULL argument from generated C++ code · ff8a6039
    Orivej Desh authored Jul 31, 2018
    C++ allows NULL to be a literal 0 [1], and this actually happens on some Linux
    systems when linux/stddef.h happens to be included [2]. When 0 is passed to a
    variadic function as a 7th or later argument, it is passed on the stack, and
    Clang encodes this on AMD64 with "mov dword ptr [rsp], 0" because it is an
    int. This sets lower 32 bits to zero, but leaves upper 32 bits unchanged.
    When they happen to be non zero, the called function that expects the last
    argument to be a zero pointer reads past the last intended argument and
    eventually segfaults.
    
    [1] https://en.cppreference.com/w/cpp/types/NULL
    [2] https://stackoverflow.com/a/31285400/1687334
    [3] https://godbolt.org/g/o4Av7Q
    ff8a6039
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7