Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Racket embedding #10

Draft
wants to merge 25 commits into
base: excelsior
Choose a base branch
from

Conversation

LiberalArtist
Copy link
Contributor

This is very much not ready to merge, but it builds with Guix and gets as far as, for example, this error (when opening smol-lang-test.rkt):

$ /gnu/store/8313508vk2fmanlg5lzj5h02yjnsca6p-tangerine-0.0/bin/tangerine 
Setting up SDL2... Done!
Setting up OpenGL... Done!
Setting up Racket CS... Done!
Setting up Dear ImGui... Done!
Using device: Mesa Intel(R) UHD Graphics (TGL GT1) 4.6 (Core Profile) Mesa 21.3.8
RacketErrorCallback: implementation not found
  arguments...:
   "open-input-file: cannot open input file\n  path: /gnu/store/5b37m8c2l6xfby6yrag451ci5hzbgc9d-racket-vm-cs-8.8/opt/racket-vm/collects/s-exp/main.rkt\n  system error: No such file or directory; errno=2\n  context...:\n   /gnu/store/5b37m8c2l6xfby6yrag451...
  context...:
   /gnu/store/5b37m8c2l6xfby6yrag451ci5hzbgc9d-racket-vm-cs-8.8/opt/racket-vm/collects/racket/private/more-scheme.rkt:163:2: select-handler/no-breaks
   /gnu/store/hk90h875bh8mxzc5s6697zpxgycaqxlm-racket-tangerine-0.0-0.develop-pkgs/lib/racket/guix/pkgs/tangerine/main.rkt:107:0: renderer-load-and-process-model

… which indicates that Racket is definitely running!

An installation path like "/usr/share/tangerine/" might be read-only.

Define the CPP macro `TANGERINE_SELF_CONTAINED` to use a path relative
to the executable, instead. Currently, Windows always uses
`TANGERINE_SELF_CONTAINED`, but support for both options could be
useful there, too.
Without this change, if you started Tangerine with some saved bookmarks
and removed them all, the update would not be saved.
This reverts commit 167e1a9aac13cd59e97f18b53755c547e1ade484.

(cherry picked from commit 9cc76c10fe58cb159b69520f4d8e0ee5becb5a09)
This avoids dependencies on Scribble and `racket/draw`.

(cherry picked from commit 9687447)
(cherry picked from commit bc2c7cb56308c8c67964177a9d66e59ea95db9b5)
(cherry picked from commit eacaa63)
(cherry picked from commit 7d39d8ab333fe8c799b901e82ebe885149613de9)
(cherry picked from commit 6895a7561965167cd887b8155b33335bc71b27e6)
The same file is at: third_party/sdl2/lib/x86/SDL2.dll

(cherry picked from commit 93d6167)
(cherry picked from commit dba18b4bd2d647bd8630a970056bdc2c6d0fc938)
(cherry picked from commit f0d7678f2cfa992adf791843df83c92b6a7884f0)
(cherry picked from commit 377bc279cbeac03172200bb6a68cbad5a2b011aa)
(cherry picked from commit 84c62f305de907c83c3bd29edb02c17eef6e009b)
(cherry picked from commit a2de611af254e801248af51ac7476c7c399cff3c)
(cherry picked from commit 3c159c50f446d26e1c10ace7dffd727cfd864c01)
If `lib-search-dirs` looks like this:

```
      (lib-search-dirs
       .
       (#f
        "/gnu/store/amkv7si0qa8s6q84a4qxwlpjs06hkdza-racket-vm-cs-8.7/opt/racket
-vm/lib"
        "/gnu/store/xmzx5mzv4863yw9kmr2ykndgp37p8if0-sqlite-3.36.0/lib"
        "/gnu/store/plr00nij45964cyy7sfcg5rcsi8hks0h-openssl-1.1.1l/lib"))
```

... we don't want the last one, actually.

Maybe we should just return the list?

(cherry picked from commit 0408d6f1117669526b31ff93b55e8eef2c4264d0)
(cherry picked from commit 8de88a60cb691d074b1372753fbf043a47220818)
(cherry picked from commit a5b1cd006b3ee9097f60321147eab791454d0de5)
@LiberalArtist LiberalArtist mentioned this pull request Feb 23, 2023
@LiberalArtist
Copy link
Contributor Author

This PR depends on #7. It also includes commits from #9, but those are conceptually separate. Needless to say, the history will need some squashing.

@Aeva
Copy link
Owner

Aeva commented Feb 24, 2023

… which indicates that Racket is definitely running!

oh wow

Aeva added a commit that referenced this pull request May 12, 2023
Remarkably this change seems to prevent this use-after-free error:

==4284==ERROR: AddressSanitizer: heap-use-after-free on address 0x60700003cf50 at pc 0x7f22b904814b bp 0x7ffda5338480 sp 0x7ffda5337c30
READ of size 79 at 0x60700003cf50 thread T0
    #0 0x7f22b904814a in __interceptor_memcpy ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
    #1 0x560430138ab6 in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .constprop.0] (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2f0ab6)
    #2 0x5604301421c6 in ifd::FileDialog::m_setDirectory(std::filesystem::__cxx11::path const&, bool) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fa1c6)
    #3 0x5604301456aa in ifd::FileDialog::m_renderContent() (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fd6aa)
    #4 0x560430145e6b in ifd::FileDialog::m_renderFileDialog() (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fde6b)
    #5 0x5604301464f7 in ifd::FileDialog::IsDone(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fe4f7)
    #6 0x5604300678b4 in RenderUI(SDL_Window*, bool&) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x21f8b4)
    #7 0x56043006fa0e in MainLoop() (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x227a0e)
    #8 0x56042fe898fa in main (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x418fa)
    #9 0x7f22b8967189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #10 0x7f22b8967244 in __libc_start_main_impl ../csu/libc-start.c:381
    #11 0x56042fe8b8c0 in _start (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x438c0)

0x60700003cf50 is located 0 bytes inside of 80-byte region [0x60700003cf50,0x60700003cfa0)
freed by thread T0 here:
    #0 0x7f22b90ba3c8 in operator delete(void*, unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:164
    #1 0x56043014210a in ifd::FileDialog::m_setDirectory(std::filesystem::__cxx11::path const&, bool) (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2fa10a)

previously allocated by thread T0 here:
    #0 0x7f22b90b94c8 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x560430138a9b in void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .constprop.0] (/home/aeva/Projects/tangerine/linux/build/Release/bin/tangerine+0x2f0a9b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants