server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: Segmentation Fault on files:scan with generate-metadata flag

Open beanaroo opened this issue 2 years ago • 0 comments
trafficstars

⚠️ This issue respects the following points: ⚠️

  • [X] This is a bug, not a question or a configuration/webserver/proxy issue.
  • [X] This issue is not already reported on Github (I've searched it).
  • [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • [X] Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • [X] I agree to follow Nextcloud's Code of Conduct.

Bug description

Running the following command works as expected:

$ php occ -v files:scan --path /user/files/Photos/example.jpg
Starting scan for user 1 out of 1 (mikki)
        File    /user/files/Photos/example.jpg

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 1     | 00:00:00     |
+---------+-------+--------------+

Providing the flag for generating metadata causes the same filename to be printed until the occ command segfaults, resulting in a leftover file lock that needs to be manually cleared.

$ php occ -v files:scan --path /user/files/Photos/example.jpg --generate-metadata

...

        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
Segmentation fault (core dumped)

Interrupting this process, when specifying the path to a single file as done above, shows the file counter has been incrementing too:

$ php occ -v files:scan --path /user/files/Photos/example.jpg --generate-metadata

...

        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
        File    /user/files/Photos/example.jpg
^C      File    /user/files/Photos/example.jpg
Interrupted by user


+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 9801  | 00:00:13     |
+---------+-------+--------------+

Steps to reproduce

  1. Execute: php occ -v files:scan --path /user/files/Photos/example.jpg --generate-metadata

Expected behavior

File scanning to succeed

Installation method

Community Docker image

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • [X] Default user-backend (database)
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Configuration report

{
    "system": {
        "default_locale": "en_NZ",
        "default_phone_region": "NZ",
        "htaccess.RewriteBase": "\/",
        "allow_local_remote_servers": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "25.0.2.3",
        "overwritehost": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "loglevel": 1,
        "maintenance": false,
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "app_install_overwrite": [
            "cookbook"
        ]
    }
}

List of activated Apps

Enabled:
  - activity: 2.17.0
  - bookmarks: 12.0.0
  - bruteforcesettings: 2.5.0
  - calendar: 4.1.2
  - cloud_federation_api: 1.8.0
  - comments: 1.15.0
  - contacts: 5.0.2
  - contactsinteraction: 1.6.0
  - cookbook: 0.10.1
  - dashboard: 7.5.0
  - dav: 1.24.0
  - deck: 1.8.2
  - federatedfilesharing: 1.15.0
  - federation: 1.15.0
  - files: 1.20.1
  - files_pdfviewer: 2.6.0
  - files_rightclick: 1.4.0
  - files_sharing: 1.17.0
  - files_trashbin: 1.15.0
  - files_versions: 1.18.0
  - firstrunwizard: 2.14.0
  - logreader: 2.10.0
  - lookup_server_connector: 1.13.0
  - maps: 0.2.1
  - nextcloud_announcements: 1.14.0
  - notifications: 2.13.1
  - oauth2: 1.13.0
  - onlyoffice: 7.6.8
  - password_policy: 1.15.0
  - photos: 2.0.1
  - previewgenerator: 5.1.1
  - privacy: 1.9.0
  - provisioning_api: 1.15.0
  - recommendations: 1.4.0
  - related_resources: 1.0.3
  - serverinfo: 1.15.0
  - settings: 1.7.0
  - sharebymail: 1.15.0
  - support: 1.8.0
  - survey_client: 1.13.0
  - systemtags: 1.15.0
  - tasks: 0.14.5
  - text: 3.6.0
  - theming: 2.0.1
  - twofactor_backupcodes: 1.14.0
  - twofactor_totp: 7.0.0
  - updatenotification: 1.15.0
  - user_status: 1.5.0
  - viewer: 1.9.0
  - weather_status: 1.5.0
  - workflowengine: 2.7.0

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Nothing relevant or within time range of error

Additional info

I suspect something may be happening in this part of the code:

https://github.com/nextcloud/server/blob/175ac79f97aaed351a192ba18f1d10e0ec939c49/apps/files/lib/Command/Scan.php#L135

beanaroo avatar Dec 26 '22 03:12 beanaroo