raylibtech / rtools

rtools feedback and issues
17 stars 1 forks source link

[rrespacker] `SIGSESV` on directory drag & drop #27

Closed mochaaP closed 1 year ago

mochaaP commented 1 year ago

Environment

Steps to reproduce

mkdir /tmp/crash
echo Hello world > /tmp/crash/demo.txt

Extra information

This crash seems to be Linux-only. Running the Windows version with Wine works fine.

Ling-Lang commented 1 year ago

The same happened to me

raysan5 commented 1 year ago

@mochaaP @Ling-Lang Thanks for reporting, I will look into it as soon as possible.

mochaaP commented 1 year ago

some strace:

openat(AT_FDCWD, "rrespacker-crash", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 10
newfstatat(10, "", {st_mode=S_IFDIR|0755, st_size=60, ...}, AT_EMPTY_PATH) = 0
close(10)                               = 0
openat(AT_FDCWD, "rrespacker-crash", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 10
newfstatat(10, "", {st_mode=S_IFDIR|0755, st_size=60, ...}, AT_EMPTY_PATH) = 0
close(10)                               = 0
brk(0x561ac601b000)                     = 0x561ac601b000
brk(0x561ac603c000)                     = 0x561ac603c000
brk(0x561ac605d000)                     = 0x561ac605d000
brk(0x561ac607e000)                     = 0x561ac607e000
brk(0x561ac609f000)                     = 0x561ac609f000
brk(0x561ac60c0000)                     = 0x561ac60c0000
brk(0x561ac60e1000)                     = 0x561ac60e1000
brk(0x561ac6102000)                     = 0x561ac6102000
brk(0x561ac6123000)                     = 0x561ac6123000
brk(0x561ac6144000)                     = 0x561ac6144000
brk(0x561ac6165000)                     = 0x561ac6165000
brk(0x561ac6186000)                     = 0x561ac6186000
brk(0x561ac61a7000)                     = 0x561ac61a7000
brk(0x561ac61c8000)                     = 0x561ac61c8000
brk(0x561ac61e9000)                     = 0x561ac61e9000
brk(0x561ac620a000)                     = 0x561ac620a000
brk(0x561ac622b000)                     = 0x561ac622b000
brk(0x561ac624c000)                     = 0x561ac624c000
brk(0x561ac626d000)                     = 0x561ac626d000
brk(0x561ac628e000)                     = 0x561ac628e000
brk(0x561ac62af000)                     = 0x561ac62af000
brk(0x561ac62d0000)                     = 0x561ac62d0000
brk(0x561ac62f1000)                     = 0x561ac62f1000
brk(0x561ac6312000)                     = 0x561ac6312000
brk(0x561ac6333000)                     = 0x561ac6333000
brk(0x561ac6354000)                     = 0x561ac6354000
brk(0x561ac6375000)                     = 0x561ac6375000
brk(0x561ac6396000)                     = 0x561ac6396000
brk(0x561ac63b7000)                     = 0x561ac63b7000
brk(0x561ac63d8000)                     = 0x561ac63d8000
brk(0x561ac63f9000)                     = 0x561ac63f9000
brk(0x561ac641a000)                     = 0x561ac641a000
brk(0x561ac643b000)                     = 0x561ac643b000
brk(0x561ac645c000)                     = 0x561ac645c000
brk(0x561ac647d000)                     = 0x561ac647d000
brk(0x561ac649e000)                     = 0x561ac649e000
brk(0x561ac64bf000)                     = 0x561ac64bf000
brk(0x561ac64e0000)                     = 0x561ac64e0000
brk(0x561ac6501000)                     = 0x561ac6501000
brk(0x561ac6522000)                     = 0x561ac6522000
brk(0x561ac6543000)                     = 0x561ac6543000
brk(0x561ac6564000)                     = 0x561ac6564000
brk(0x561ac6585000)                     = 0x561ac6585000
brk(0x561ac65a6000)                     = 0x561ac65a6000
brk(0x561ac65c7000)                     = 0x561ac65c7000
brk(0x561ac65e8000)                     = 0x561ac65e8000
brk(0x561ac6609000)                     = 0x561ac6609000
brk(0x561ac662a000)                     = 0x561ac662a000
brk(0x561ac664b000)                     = 0x561ac664b000
brk(0x561ac666c000)                     = 0x561ac666c000
brk(0x561ac668d000)                     = 0x561ac668d000
brk(0x561ac66ae000)                     = 0x561ac66ae000
brk(0x561ac66cf000)                     = 0x561ac66cf000
brk(0x561ac66f0000)                     = 0x561ac66f0000
brk(0x561ac6711000)                     = 0x561ac6711000
brk(0x561ac6732000)                     = 0x561ac6732000
brk(0x561ac6753000)                     = 0x561ac6753000
brk(0x561ac6774000)                     = 0x561ac6774000
brk(0x561ac6795000)                     = 0x561ac6795000
brk(0x561ac67b6000)                     = 0x561ac67b6000
brk(0x561ac67d7000)                     = 0x561ac67d7000
brk(0x561ac67f8000)                     = 0x561ac67f8000
brk(0x561ac6819000)                     = 0x561ac6819000
brk(0x561ac683a000)                     = 0x561ac683a000
brk(0x561ac685b000)                     = 0x561ac685b000
brk(0x561ac687c000)                     = 0x561ac687c000
brk(0x561ac689d000)                     = 0x561ac689d000
brk(0x561ac68be000)                     = 0x561ac68be000
brk(0x561ac68df000)                     = 0x561ac68df000
brk(0x561ac6900000)                     = 0x561ac6900000
brk(0x561ac6921000)                     = 0x561ac6921000
brk(0x561ac6942000)                     = 0x561ac6942000
brk(0x561ac6963000)                     = 0x561ac6963000
brk(0x561ac6984000)                     = 0x561ac6984000
brk(0x561ac69a5000)                     = 0x561ac69a5000
brk(0x561ac69c6000)                     = 0x561ac69c6000
brk(0x561ac69e7000)                     = 0x561ac69e7000
brk(0x561ac6a08000)                     = 0x561ac6a08000
brk(0x561ac6a29000)                     = 0x561ac6a29000
brk(0x561ac6a4a000)                     = 0x561ac6a4a000
brk(0x561ac6a6b000)                     = 0x561ac6a6b000
brk(0x561ac6a8c000)                     = 0x561ac6a8c000
brk(0x561ac6aad000)                     = 0x561ac6aad000
brk(0x561ac6ace000)                     = 0x561ac6ace000
brk(0x561ac6aef000)                     = 0x561ac6aef000
brk(0x561ac6b10000)                     = 0x561ac6b10000
brk(0x561ac6b31000)                     = 0x561ac6b31000
brk(0x561ac6b52000)                     = 0x561ac6b52000
brk(0x561ac6b73000)                     = 0x561ac6b73000
brk(0x561ac6b94000)                     = 0x561ac6b94000
brk(0x561ac6bb5000)                     = 0x561ac6bb5000
brk(0x561ac6bd6000)                     = 0x561ac6bd6000
brk(0x561ac6bf7000)                     = 0x561ac6bf7000
brk(0x561ac6c18000)                     = 0x561ac6c18000
brk(0x561ac6c39000)                     = 0x561ac6c39000
brk(0x561ac6c5a000)                     = 0x561ac6c5a000
brk(0x561ac6c7b000)                     = 0x561ac6c7b000
brk(0x561ac6c9c000)                     = 0x561ac6c9c000
brk(0x561ac6cbd000)                     = 0x561ac6cbd000
brk(0x561ac6cde000)                     = 0x561ac6cde000
brk(0x561ac6cff000)                     = 0x561ac6cff000
brk(0x561ac6d20000)                     = 0x561ac6d20000
brk(0x561ac6d41000)                     = 0x561ac6d41000
brk(0x561ac6d62000)                     = 0x561ac6d62000
brk(0x561ac6d83000)                     = 0x561ac6d83000
brk(0x561ac6da4000)                     = 0x561ac6da4000
brk(0x561ac6dc5000)                     = 0x561ac6dc5000
brk(0x561ac6de6000)                     = 0x561ac6de6000
brk(0x561ac6e07000)                     = 0x561ac6e07000
brk(0x561ac6e28000)                     = 0x561ac6e28000
brk(0x561ac6e49000)                     = 0x561ac6e49000
brk(0x561ac6e6a000)                     = 0x561ac6e6a000
brk(0x561ac6e8b000)                     = 0x561ac6e8b000
brk(0x561ac6eac000)                     = 0x561ac6eac000
brk(0x561ac6ecd000)                     = 0x561ac6ecd000
brk(0x561ac6eee000)                     = 0x561ac6eee000
brk(0x561ac6f0f000)                     = 0x561ac6f0f000
brk(0x561ac6f30000)                     = 0x561ac6f30000
brk(0x561ac6f51000)                     = 0x561ac6f51000
brk(0x561ac6f72000)                     = 0x561ac6f72000
brk(0x561ac6f93000)                     = 0x561ac6f93000
brk(0x561ac6fb4000)                     = 0x561ac6fb4000
brk(0x561ac6fd5000)                     = 0x561ac6fd5000
brk(0x561ac6ff6000)                     = 0x561ac6ff6000
brk(0x561ac7017000)                     = 0x561ac7017000
openat(AT_FDCWD, "rrespacker-crash", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 10
newfstatat(10, "", {st_mode=S_IFDIR|0755, st_size=60, ...}, AT_EMPTY_PATH) = 0
getdents64(10, 0x561ac7006e00 /* 3 entries */, 32768) = 80
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x5cc} ---
+++ killed by SIGSEGV (core dumped) +++
Segmentation fault (core dumped)
mochaaP commented 1 year ago

I think it crashed somewhere near 0x3f85c. If you have debug symbols please take a look at there.

raysan5 commented 1 year ago

It seems related to the path scanning methods in raylib: LoadDirectoryFiles*(), they were updated recently. You can try https://github.com/raysan5/raylib/blob/master/examples/core/core_drop_files.c raylib example, the method used by rrespacker is the same.

I don't have a proper Linux environment at the moment so it can take me some time to review... sorry for the inconvenience...

mochaaP commented 1 year ago

after doing a quick git bisect:

b8f67c628553cb9199f51efc9b20eb5991d58e8f is the first bad commit
commit b8f67c628553cb9199f51efc9b20eb5991d58e8f
Author: Ray <raysan5@gmail.com>
Date:   Sat Jun 11 23:24:13 2022 +0200

    WARNING: BREAKING: REDESIGNED: Filepath loading API

    REDESIGNED: `LoadDirectoryFiles()`
    ADDED: `LoadDirectoryFilesEx()`
    REDESIGNED: `LoadDroppedFiles()`
    ADDED: `IsPathFile()`

    This BIG BREAKING change simplifies the functions and gives more control to the user:
     - A new `struct FilePathList` has been added to avoid exposing complex pointers.
     - User is responsible of memory loading/unloading
     - Filepaths loading support recursive directories and file extension filters

 examples/core/core_drop_files.c   |  13 +-
 examples/models/models_loading.c  |  25 ++--
 examples/models/models_skybox.c   |  13 +-
 examples/text/text_draw_3d.c      |  14 +--
 examples/text/text_font_filters.c |  10 +-
 src/raylib.h                      |  20 ++-
 src/rcore.c                       | 252 +++++++++++++++++++++++++++++---------
 7 files changed, 247 insertions(+), 100 deletions(-)

expected behavior: shows dropped file until next drop

current behavior: shows dropped file correctly for one frame


some extra testings:

LoadDirectoryFiles and LoadDirectoryFilesEx works without issues.

mochaaP commented 1 year ago

I guess I found the error.

While building against 4.2.0, LoadDirectoryFiles results in error:

INFO: Dropped files: /tmp/crash
WARNING: FILEIO: Directory cannot be opened ()
WARNING: FILEIO: Directory cannot be opened ()
WARNING: FILEIO: Directory cannot be opened ()
WARNING: FILEIO: Directory cannot be opened ()

https://github.com/raysan5/raylib/blob/4.2.0/src/rcore.c#L5197

doing a quick git bisect shows:

5530a3ceb88962066affa5db8e13b00b64444b37 is the first fixed commit
commit 5530a3ceb88962066affa5db8e13b00b64444b37
Author: Ray <raysan5@gmail.com>
Date:   Mon Sep 19 18:20:36 2022 +0200

    REVIEWED: `ScanDirectoryFilesRecursively()`, fix #2704

 src/rcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Could you consider a patch release containing those REVIEW fixes? Thanks.

(btw, the demo issue is still present.)

mochaaP commented 1 year ago

cc @raysan5

mochaaP commented 1 year ago

@raysan5 as raylib 4.5 have been released, could you release a new build?

raysan5 commented 1 year ago

@mochaaP I'll try to release an update as soon as possible.

raysan5 commented 1 year ago

@mochaaP Just updated rrespacker with some improvements: https://raylibtech.itch.io/rrespacker/devlog/517010/rrespacker-v12-published

Please, let me know if now it works as expected.

mochaaP commented 1 year ago

Thanks ;)