nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.38k stars 4.07k forks source link

Exception: Failed to start session #19200

Closed kaipee closed 4 years ago

kaipee commented 4 years ago

Steps to reproduce

Unknown what caused the issue. Errors are shown in Administration > Logging

Expected behaviour

No errors

Actual behaviour

Errors

Server configuration detail

Operating system: Linux 4.15.0-74-generic #84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64

Webserver: Apache (fpm-fcgi)

Database: pgsql PostgreSQL 10.10 (Ubuntu 10.10-0ubuntu0.18.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit

PHP version:

7.2.24-0ubuntu0.18.04.2 Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, sodium, session, standard, cgi-fcgi, json, apcu, igbinary, PDO, xml, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, gmp, iconv, imagick, imap, intl, redis, ldap, exif, pdo_pgsql, pgsql, Phar, posix, readline, shmop, SimpleXML, smbclient, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, libsmbclient, Zend OPcache

Nextcloud version: 17.0.2 - 17.0.2.1

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: unknown

Signing status Array ( )
List of activated apps ``` Enabled: - accessibility: 1.3.0 - activity: 2.10.1 - admin_audit: 1.7.0 - audioplayer: 2.9.0 - bookmarks: 2.3.4 - calendar: 2.0.1 - cloud_federation_api: 1.0.0 - comments: 1.7.0 - contacts: 3.1.8 - dav: 1.13.0 - drawio: 0.9.4 - extract: 1.2.3 - federatedfilesharing: 1.7.0 - federation: 1.7.0 - files: 1.12.0 - files_accesscontrol: 1.7.0 - files_external: 1.8.0 - files_markdown: 2.2.0 - files_mindmap: 0.0.15 - files_pdfviewer: 1.6.0 - files_rightclick: 0.15.1 - files_sharing: 1.9.0 - files_trashbin: 1.7.0 - files_versions: 1.10.0 - files_videoplayer: 1.6.0 - firstrunwizard: 2.6.0 - gallery: 18.4.0 - impersonate: 1.4.0 - issuetemplate: 0.6.0 - logreader: 2.2.0 - lookup_server_connector: 1.5.0 - nextbackup: 19.12.1 - nextcloud_announcements: 1.6.0 - notes: 3.1.1 - notifications: 2.5.0 - oauth2: 1.5.0 - password_policy: 1.7.0 - previewgenerator: 2.2.0 - privacy: 1.1.0 - provisioning_api: 1.7.0 - qownnotesapi: 20.1.0 - recommendations: 0.5.0 - serverinfo: 1.7.0 - sharebymail: 1.7.0 - support: 1.0.1 - survey_client: 1.5.0 - suspicious_login: 3.0.1 - systemtags: 1.7.0 - tasks: 0.11.3 - text: 1.1.1 - theming: 1.8.0 - twofactor_backupcodes: 1.6.0 - updatenotification: 1.7.0 - viewer: 1.2.0 - workflowengine: 1.7.0 Disabled: - encryption - user_ldap ```
Configuration (config/config.php) ``` { "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "localhost", "192.168.0.78", "nextcloud", "nextcloud.kphm.kaipee.co.uk", "kphmsrv.kaipee.co.uk" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "pgsql", "version": "17.0.2.1", "overwrite.cli.url": "https:\/\/nextcloud.kphm.kaipee.co.uk\/", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "instanceid": "***REMOVED SENSITIVE VALUE***", "log_type": "file", "logfile": "\/var\/log\/nextcloud\/nextcloud.log", "loglevel": "2", "mail_smtpmode": "smtp", "remember_login_cookie_lifetime": "1800", "log_rotate_size": "10485760", "trashbin_retention_obligation": "auto, 180", "versions_retention_obligation": "auto, 365", "simpleSignUpLink.shown": "false", "memcache.local": "\\OC\\Memcache\\APCu", "filelocking.enabled": true, "memcache.distributed": "\\OC\\Memcache\\Redis", "memcache.locking": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 0, "timeout": 0.5, "dbindex": 0, "password": "***REMOVED SENSITIVE VALUE***" }, "logtimezone": "Europe\/London", "htaccess.RewriteBase": "\/", "enable_previews": true, "enabledPreviewProviders": [ "OC\\Preview\\PNG", "OC\\Preview\\JPEG", "OC\\Preview\\GIF", "OC\\Preview\\BMP", "OC\\Preview\\MarkDown", "OC\\Preview\\MP3", "OC\\Preview\\TXT", "OC\\Preview\\Movie", "OC\\Preview\\Photoshop", "OC\\Preview\\SVG", "OC\\Preview\\TIFF" ], "preview_max_x": "2048", "preview_max_y": "2048", "jpeg_quality": "60", "maintenance": false, "mail_smtpsecure": "tls", "mail_sendmailmode": "smtp", "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpport": "587", "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***", "trusted_proxies": "***REMOVED SENSITIVE VALUE***", "overwritehost": "kphmsrv.kaipee.co.uk:58443", "overwriteprotocol": "https", "overwritecondaddr": "^192\\.168\\.0\\.77$" } ```

Are you using external storage, if yes which one: local/smb/sftp/...

Are you using encryption:

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

Client configuration

Browser: Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0

Operating system:

Logs

Web server error log ``` Insert your web server log here ```
Nextcloud log ``` [base] Error: Exception: Failed to start session at <> 0. /var/www/nextcloud/lib/base.php line 424 OC\Session\Internal->__construct("ocuezijab7zo") 1. /var/www/nextcloud/lib/base.php line 642 OC::initSession() 2. /var/www/nextcloud/lib/base.php line 1078 OC::init() 3. /var/www/nextcloud/index.php line 40 undefinedundefinedrequire_once("/var/www/nextcloud/lib/base.php") GET /login from **.**.**.** at 2020-01-25T18:18:48+00:00 ```
Browser log Insert your browser log here, this could for example include: a) The javascript console log b) The network log c) ...
kesselb commented 4 years ago

https://github.com/nextcloud/server/blob/ca964cfe9fa0c0e5b097e61933d67a45a5fa3b2d/lib/private/Session/Internal.php#L64-L66

That's the code in question. I have no idea how to run into such a situation. You changed some sessions related settings with php / the session.save_path is writeable?

kaipee commented 4 years ago

Nope I haven't modified any PHP files on the server.

Where would the session.save_path be located?

kesselb commented 4 years ago

Where would the session.save_path be located?

https://www.php.net/manual/en/session.configuration.php#ini.session.save-path

kaipee commented 4 years ago
root@nextcloud:/var/www# php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php/7.2/cli
Loaded Configuration File => /etc/php/7.2/cli/php.ini

root@nextcloud:/var/www# php -i | grep save_path
session.save_path => /var/lib/php/sessions => /var/lib/php/sessions

root@nextcloud:/var/www# ls -ald /var/lib/php/sessions
drwx-wx-wt 2 root root 12288 Jan 29 18:41 /var/lib/php/sessions

root@nextcloud:/var/www# ls -al /var/lib/php/sessions/
total 92
drwx-wx-wt 2 root     root     12288 Jan 29 18:41 .
drwxr-xr-x 4 root     root      4096 Jan  2 19:05 ..
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_19hjhbr15al1qhruusndaa9pls
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_3l5eti8tmhr1q31k3vh31phb69
-rw------- 1 www-data www-data   403 Jan 29 18:59 sess_6ahngl31hl2le8ahj2kti5kde5
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_7m9fqfnhjkd27pmluckd4cmuvl
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_7pulms379n1frqenfma60j5lj4
-rw------- 1 www-data www-data   787 Jan 29 18:38 sess_94u3igr4p775c4bbofnfjhnmo4
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_9q3qa9p1pnunbs5fj1nvpg7nke
-rw------- 1 www-data www-data   787 Jan 29 18:38 sess_bd63kt6res0bofihg0qu37rqnp
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_bmt8kdpi2obkt7bp5ltpm8o29c
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_c9f3vegri9f1qnhsug1niqddt8
-rw------- 1 www-data www-data   787 Jan 29 18:38 sess_cps231mbp3t4t7edtg51nr35uh
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_fc8g2ntlltscmr402gkbhdgsg0
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_getlp20ihulpvi81vsru1qac88
-rw------- 1 www-data www-data   787 Jan 29 18:38 sess_hqg43j6ps440jl6u5or7f9iqff
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_ja6v2jb2p6lpd9poenfs1mcrgd
-rw------- 1 www-data www-data   403 Jan 29 18:22 sess_ltkarn7uuo1p85k30ak6p3ihf0
-rw------- 1 www-data www-data   787 Jan 29 18:41 sess_nf1u3h6qcshenalsknj1u5irfn
-rw------- 1 www-data www-data   787 Jan 29 18:38 sess_qemptirm43cu6iuf0fi5uahvec
-rw------- 1 www-data www-data   403 Jan 29 18:59 sess_t8en67up4u7n2bigqpfbf1jdpu
kaipee commented 4 years ago
root@nextcloud:/var/www# find / -type f -iname "php.ini"
/etc/php/7.2/cli/php.ini
/etc/php/7.2/fpm/php.ini
/var/www/nextcloud/apps/nextbackup/tests/travis/php.ini
/var/www/nextcloud/apps/qownnotesapi/tests/travis/php.ini

Here are both php.ini files (filtered for 'session')

/etc/php/7.2/cli/php.ini

session
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => no value => no value
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 0 => 0
session.lazy_write => On => On
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /var/lib/php/sessions => /var/lib/php/sessions
session.serialize_handler => php => php
session.sid_bits_per_character => 5 => 5
session.sid_length => 26 => 26
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => 1 => 1
session.use_only_cookies => 1 => 1
session.use_strict_mode => 0 => 0
session.use_trans_sid => 0 => 0
session.trans_sid_hosts => no value => no value
session.trans_sid_tags => a=href,area=href,frame=src,form= => a=href,area=href,frame=src,form=

/etc/php/7.2/fpm/php.ini

session
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => no value => no value
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 0 => 0
session.lazy_write => On => On
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /var/lib/php/sessions => /var/lib/php/sessions
session.serialize_handler => php => php
session.sid_bits_per_character => 5 => 5
session.sid_length => 26 => 26
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => 1 => 1
session.use_only_cookies => 1 => 1
session.use_strict_mode => 0 => 0
session.use_trans_sid => 0 => 0
session.trans_sid_hosts => no value => no value
session.trans_sid_tags => a=href,area=href,frame=src,form= => a=href,area=href,frame=src,form=
ghost commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

kaipee commented 4 years ago

Issue still persists

kesselb commented 4 years ago

Hmm. $_SESSION is not available. That's a php internal. I doubt that has anything to do with Nextcloud.

Index: lib/private/Session/Internal.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/private/Session/Internal.php    (revision 90c3e3bbeb566f73952f7e4c66b9f98ec84cdde2)
+++ lib/private/Session/Internal.php    (date 1582987817704)
@@ -54,15 +54,17 @@
     */
    public function __construct(string $name) {
        set_error_handler([$this, 'trapError']);
+       $error = '';
        $this->invoke('session_name', [$name]);
        try {
            $this->startSession();
        } catch (\Exception $e) {
+           $error = $e->getMessage();
            setcookie($this->invoke('session_name'), '', -1, \OC::$WEBROOT ?: '/');
        }
        restore_error_handler();
        if (!isset($_SESSION)) {
-           throw new \Exception('Failed to start session');
+           throw new \Exception('Failed to start session: "' . $error . '"');
        }
    }

The above patch should add some more information to the error message.

kaipee commented 4 years ago

I've added the patch, I'll keep an eye on the next error, thanks.

ghost commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

kaipee commented 4 years ago

Looks like the patch fixed the issue. Thanks for the help

matthieu-labas commented 1 year ago

The patch was supposed to show information about the error, not to correct anything... Did you do something later to fix this issue? I'm having the same problem with an empty error message reported (i.e. the $_SESSION is not set).

matthieu-labas commented 1 year ago

I was able to track it down to session_start() call failing:

Error 2: session_start(): Cannot find session serialization handler &quot;igbinary&quot; - session startup failed
matthieu-labas commented 1 year ago

I had the problem after upgrading PHP version from 7.4 to 8.1. Some packages were missing, which included the php-igbinary that I had to reinstall manually. The error was gone after that.