Bug 1770072 - [abrt] ibus-typing-booster: makedirs(): os.py:221:makedirs:FileExistsError: [Errno 17] File exists: '/home/glassy/.local/share/ibus-typing-booster/data'
Summary: [abrt] ibus-typing-booster: makedirs(): os.py:221:makedirs:FileExistsError: [...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ibus-typing-booster
Version: 31
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mike FABIAN
QA Contact: Fedora Extras Quality Assurance
URL: https://retrace.fedoraproject.org/faf...
Whiteboard: abrt_hash:2670921efebf7bcad72573b1e26...
: 1772726 1773746 1777669 1778433 1778985 1779424 1780080 1780957 1789064 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-08 04:02 UTC by ropermantena
Modified: 2020-02-17 15:20 UTC (History)
15 users (show)

Fixed In Version: ibus-typing-booster-2.7.3-1.fc30 ibus-typing-booster-2.7.3-1.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-12-05 01:10:34 UTC
Type: ---


Attachments (Terms of Use)
File: backtrace (1.22 KB, text/plain)
2019-11-08 04:02 UTC, ropermantena
no flags Details
File: cpuinfo (2.33 KB, text/plain)
2019-11-08 04:02 UTC, ropermantena
no flags Details
File: environ (1.65 KB, text/plain)
2019-11-08 04:02 UTC, ropermantena
no flags Details
File: mountinfo (2.56 KB, text/plain)
2019-11-08 04:02 UTC, ropermantena
no flags Details
File: namespaces (129 bytes, text/plain)
2019-11-08 04:02 UTC, ropermantena
no flags Details
File: open_fds (1.09 KB, text/plain)
2019-11-08 04:02 UTC, ropermantena
no flags Details

Description ropermantena 2019-11-08 04:02:04 UTC
Version-Release number of selected component:
ibus-typing-booster-2.7.0-1.fc31

Additional info:
reporter:       libreport-2.10.1
cgroup:         0::/user.slice/user-1000.slice/user@1000.service/gnome-shell-wayland.service
cmdline:        /usr/bin/python3 /usr/share/ibus-typing-booster/engine/main.py --xml
crash_function: makedirs
exception_type: FileExistsError
executable:     /usr/share/ibus-typing-booster/engine/main.py
interpreter:    python3-3.7.5-1.fc31.x86_64
kernel:         5.3.8-300.fc31.x86_64
runlevel:       N 5
type:           Python3
uid:            1000

Truncated backtrace:
os.py:221:makedirs:FileExistsError: [Errno 17] File exists: '/home/glassy/.local/share/ibus-typing-booster/data'

Traceback (most recent call last):
  File "/usr/share/ibus-typing-booster/engine/main.py", line 34, in <module>
    import factory
  File "/usr/share/ibus-typing-booster/engine/factory.py", line 32, in <module>
    import hunspell_table
  File "/usr/share/ibus-typing-booster/engine/hunspell_table.py", line 45, in <module>
    import itb_emoji
  File "/usr/share/ibus-typing-booster/engine/itb_emoji.py", line 78, in <module>
    USER_DATADIR = itb_util.xdg_save_data_path('ibus-typing-booster/data')
  File "/usr/share/ibus-typing-booster/engine/itb_util.py", line 3487, in xdg_save_data_path
    return xdg.BaseDirectory.save_data_path(*resource)
  File "/usr/lib/python3.7/site-packages/xdg/BaseDirectory.py", line 70, in save_data_path
    os.makedirs(path)
  File "/usr/lib64/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: '/home/glassy/.local/share/ibus-typing-booster/data'

Local variables in innermost frame:
name: '/home/glassy/.local/share/ibus-typing-booster/data'
mode: 511
exist_ok: False
head: '/home/glassy/.local/share/ibus-typing-booster'
tail: 'data'
cdir: '.'

Comment 1 ropermantena 2019-11-08 04:02:06 UTC
Created attachment 1633843 [details]
File: backtrace

Comment 2 ropermantena 2019-11-08 04:02:07 UTC
Created attachment 1633844 [details]
File: cpuinfo

Comment 3 ropermantena 2019-11-08 04:02:08 UTC
Created attachment 1633845 [details]
File: environ

Comment 4 ropermantena 2019-11-08 04:02:09 UTC
Created attachment 1633846 [details]
File: mountinfo

Comment 5 ropermantena 2019-11-08 04:02:10 UTC
Created attachment 1633847 [details]
File: namespaces

Comment 6 ropermantena 2019-11-08 04:02:11 UTC
Created attachment 1633848 [details]
File: open_fds

Comment 7 Mike FABIAN 2019-11-12 08:25:03 UTC
https://bugs.python.org/issue1675

Comment 9 Mike FABIAN 2019-11-12 08:56:08 UTC
*** Bug 1713963 has been marked as a duplicate of this bug. ***

Comment 10 Mike FABIAN 2019-11-12 08:56:24 UTC
*** Bug 1764520 has been marked as a duplicate of this bug. ***

Comment 11 Mike FABIAN 2019-11-12 08:56:36 UTC
*** Bug 1768016 has been marked as a duplicate of this bug. ***

Comment 12 Mike FABIAN 2019-11-12 08:59:15 UTC
I think this will fix it:

$ git show 
commit 5f0a46a5dbf4f99fb1eae2fd80831f60616007e9 (HEAD -> release-2.7.3)
Author: Mike FABIAN <mfabian@redhat.com>
Date:   Tue Nov 12 17:47:37 2019 +0900

    Fix race condition in itb_util.xdg_save_data_path()
    
    Resolves: rhbz#1770072 (https://bugzilla.redhat.com/show_bug.cgi?id=1770072)
    Resolves: rhbz#1713963 (https://bugzilla.redhat.com/show_bug.cgi?id=1713963)
    Resolves: rhbz#1764520 (https://bugzilla.redhat.com/show_bug.cgi?id=1764520)
    Resolves: rhbz#1768016 (https://bugzilla.redhat.com/show_bug.cgi?id=1768016)
    
    [abrt] ibus-typing-booster: makedirs(): os.py:221:makedirs:FileExistsError: [Errno 17] Fil
e exists: '/home/uncle/.local/share/ibus-typing-booster/data'

diff --git a/engine/itb_util.py b/engine/itb_util.py
index 0494a08..c53fc9b 100644
--- a/engine/itb_util.py
+++ b/engine/itb_util.py
@@ -3500,17 +3500,23 @@ def xdg_save_data_path(*resource):
     Compatibility function for systems which do not have pyxdg.
     (For example openSUSE Leap 42.1)
     '''
-    if IMPORT_XDG_BASEDIRECTORY_SUCCESSFUL:
-        return xdg.BaseDirectory.save_data_path(*resource)
+    # if IMPORT_XDG_BASEDIRECTORY_SUCCESSFUL:
+    #    return xdg.BaseDirectory.save_data_path(*resource)
+    #
+    # xdg.BaseDirectory.save_data_path(*resource) unfortunately
+    # can fail because it calls os.makedirs() without the exist_ok=True
+    # option, and then os.makedirs() can fail in a race condition
+    # (see: https://bugs.python.org/issue1675)
+    #
     # Replicate implementation of xdg.BaseDirectory.save_data_path
-    # here:
+    # here (and add the exist_ok=True parameter to os.makedirs()):
     xdg_data_home = os.environ.get('XDG_DATA_HOME') or os.path.join(
         os.path.expanduser('~'), '.local', 'share')
     resource = os.path.join(*resource)
     assert not resource.startswith('/')
     path = os.path.join(xdg_data_home, resource)
     if not os.path.isdir(path):
-        os.makedirs(path)
+        os.makedirs(path, exist_ok=True)
     return path
 
 class KeyvalsToKeycodes:
lines 1-45/45 (END)

Comment 13 Fedora Update System 2019-11-25 10:07:30 UTC
FEDORA-2019-6398f828eb has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-6398f828eb

Comment 14 Fedora Update System 2019-11-25 10:08:00 UTC
FEDORA-2019-8eb6c00da1 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-8eb6c00da1

Comment 15 Fedora Update System 2019-11-25 10:08:38 UTC
FEDORA-2019-41b9e70195 has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-41b9e70195

Comment 16 Fedora Update System 2019-11-26 16:32:26 UTC
ibus-typing-booster-2.7.3-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-6398f828eb

Comment 17 Fedora Update System 2019-11-27 00:31:45 UTC
ibus-typing-booster-2.7.3-1.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-41b9e70195

Comment 18 Fedora Update System 2019-11-27 01:07:19 UTC
ibus-typing-booster-2.7.3-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-8eb6c00da1

Comment 19 yanqiyu01 2019-11-28 03:24:42 UTC
*** Bug 1777669 has been marked as a duplicate of this bug. ***

Comment 20 Mike FABIAN 2019-12-03 05:39:38 UTC
*** Bug 1778985 has been marked as a duplicate of this bug. ***

Comment 21 Mike FABIAN 2019-12-03 05:52:29 UTC
*** Bug 1778433 has been marked as a duplicate of this bug. ***

Comment 22 Mike FABIAN 2019-12-04 10:00:09 UTC
*** Bug 1779424 has been marked as a duplicate of this bug. ***

Comment 23 Fedora Update System 2019-12-05 01:10:34 UTC
ibus-typing-booster-2.7.3-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.

Comment 24 Fedora Update System 2019-12-05 01:39:38 UTC
ibus-typing-booster-2.7.3-1.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report.

Comment 25 Mike FABIAN 2019-12-06 16:27:07 UTC
*** Bug 1780080 has been marked as a duplicate of this bug. ***

Comment 26 Mike FABIAN 2019-12-09 05:51:28 UTC
*** Bug 1780957 has been marked as a duplicate of this bug. ***

Comment 27 Mike FABIAN 2020-01-09 13:09:39 UTC
*** Bug 1789064 has been marked as a duplicate of this bug. ***

Comment 28 Mike FABIAN 2020-02-17 15:19:19 UTC
*** Bug 1772726 has been marked as a duplicate of this bug. ***

Comment 29 Mike FABIAN 2020-02-17 15:20:11 UTC
*** Bug 1773746 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.