Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 674
    • Issues 674
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #3125
Closed
Open
Created Dec 03, 2019 by Bitbucket Importer@bitbucket_importerMaintainer

Logical error in detecting dirent.d_type

Created originally on Bitbucket by Igor Pashev (Игорь Пашев)

Hi guys! I am porting Debian’s package pypy to Dyson which is Debian on illumos kernel and, so far, libc. Its dirent structure does not have d_type field, but for sure has d_name. And when I am building pypy I am getting this error:

[translation:ERROR] AttributeError: <Struct dirent { c__pad0, c__pad1, c__pad2, c__pad3, c__pad4, c__pad5, c__pad6, c__pad7, c__pad8, c__pad9, c__pad10, c__pad11, c__pad12, c__pad13, c__pad14, c__pad15, c__pad16, c__pad17, c_
_pad18, c__pad19, c__pad20, c__pad21, c__pad22, c__pad23 }> instance has no field 'c_d_name'                                                                                                                                     
Processing block:                                                                                                                                                                                                                
 block@61[rewind_0...] is a <class 'rpython.flowspace.flowcontext.SpamBlock'>                                                                                                                                                    
 in (rpython.rlib.rposix:833)_listdir                                                                                                                                                                                            
 containing the following operations:                                                                                                                                                                                            
       v831 = getattr(direntp_0, ('c_d_name'))                                                                                                                                                                                   
       namep_0 = simple_call((function force_cast), (Ptr arrayPtr), v831)                                                                                                                                                        
       name_5 = simple_call((function charp2str), namep_0)                                                                                                                                                                       
       v832 = ne(name_5, ('.'))                                                                                                                                                                                                  
       v833 = bool(v832)                                                                                                                                                                                                         
 --end--

‌

Looking at this code in rpython/rlib/rposix.py… well after hard time debugging :)… I have found a logical error:

if not _WIN32:
    class CConfig:
        _compilation_info_ = eci
        DIRENT = rffi_platform.Struct('struct dirent',
            [('d_name', lltype.FixedSizeArray(rffi.CHAR, 1)),
             ('d_ino', lltype.Signed)]
            + [('d_type', rffi.INT)] if HAVE_D_TYPE else [])
        if HAVE_D_TYPE:
            DT_UNKNOWN = rffi_platform.ConstantInteger('DT_UNKNOWN')
            DT_REG     = rffi_platform.ConstantInteger('DT_REG')
            DT_DIR     = rffi_platform.ConstantInteger('DT_DIR')
            DT_LNK     = rffi_platform.ConstantInteger('DT_LNK')

    DIRP = rffi.COpaquePtr('DIR')
    dirent_config = rffi_platform.configure(CConfig)

Guess what! :)

Yes, if HAVE_D_TYPE is False, we get empty list, without d_name, d_ino.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking