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

asyncCheck works fine on Linux and Windows - not on Mac. #15019

Closed
sergiotapia opened this issue Jul 19, 2020 · 14 comments
Closed

asyncCheck works fine on Linux and Windows - not on Mac. #15019

sergiotapia opened this issue Jul 19, 2020 · 14 comments
Labels
Async Everything related to Nim's async Waiting on Author

Comments

@sergiotapia
Copy link

@dom96 asked me to create a small sample illustrating the issue.

https://github.com/sergiotapia/async-check

The code runs well on Linux and Windows, the echos in the {.async} function are seen as expected.

On Mac, we see no echos, despite Jester serving responses.

nim -v
Nim Compiler Version 1.2.2 [MacOSX: amd64]
Compiled at 2020-06-25
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release

I hope this is just an error in my code, but if it's a Nim bug I'm sure you guys will be able to tackle it. I love Nim so far!

@snej
Copy link

snej commented Jul 20, 2020

Reproduced this with Nim 1.2.2 on macOS 10.15.5.
Tried to reproduce with latest devel, but got a compile error in Jester. Is that library not compatible?
/Users/snej/.nimble/pkgs/jester-0.4.3/jester.nim(704, 26) Error: undeclared identifier: 'initInterval'

@ghost
Copy link

ghost commented Jul 20, 2020

@snej you need jester devel for nim devel :) initInterval -> initDuration (due to removed deprecated stuff from stdlib)

@snej
Copy link

snej commented Jul 20, 2020

Looks like the main thread is blocked in joinThread, which is blocked in pthread_join, and not running any async tasks. Via the sample tool:

Call graph:
    1851 Thread_419617   DispatchQueue_1: com.apple.main-thread  (serial)
    + 1851 start  (in libdyld.dylib) + 1  [0x7fff71ee3cc9]
    +   1851 main  (in async_test) + 62  [0x10c36cc8e]
    +     1851 NimMain  (in async_test) + 42  [0x10c36cc4a]
    +       1851 NimMainInner  (in async_test) + 9  [0x10c36c9b9]
    +         1851 NimMainModule  (in async_test) + 590  [0x10c36cc0e]
    +           1851 serve__uyVGO9b8GZDPA7YPHmJyO1w  (in async_test) + 1557  [0x10c363115]
    +             1851 run__UlykqHUJzrYfskoCKJB7AQ  (in async_test) + 1043  [0x10c354a93]
    +               1851 joinThreads__khVjhz9bVAEzWbLJTwAvaVA  (in async_test) + 158  [0x10c2f2f7e]
    +                 1851 joinThread__b7SXibO9bv1Wvu9ani9anuO5gsystem  (in async_test) + 32  [0x10c2f2fc0]
    +                   1851 _pthread_join  (in libsystem_pthread.dylib) + 347  [0x7fff720e95c2]
    +                     1851 __ulock_wait  (in libsystem_kernel.dylib) + 10  [0x7fff7202655e]

@dom96
Copy link
Contributor

dom96 commented Jul 20, 2020

Ooh, thanks for trying this out @snej. I didn't get a chance to yet.

My guess from looking at this though is that this may be a httpbeast bug. Can you try compiling with -d:useStdlib?

@sergiotapia
Copy link
Author

If I use -d:useStdlib would that avoid using httpbeast? We're trying to determine if the bug is in that application?

@ghost
Copy link

ghost commented Jul 21, 2020

@sergiotapia yes, it'll avoid using httpbeast. dom96 is trying to determine if it's a nim async bug, jester bug or httpbeast bug

@sergiotapia
Copy link
Author

Trying now.

@sergiotapia
Copy link
Author

@dom96 @Yardanico @snej

Using this in my nim.cfg, the applications works fine on Mac now.

-d:ssl
-d:useStdlib
--threads:on

@ghost
Copy link

ghost commented Jul 22, 2020

@dom96 What should I do here? Does this mean I can't ship my app with it using httpbeast until the bug is fixed in that project?

@dom96
Copy link
Contributor

dom96 commented Jul 22, 2020

Yep. What kind of app is this?

@Araq
Copy link
Member

Araq commented Jul 22, 2020

You can make your config conditional like so:

-d:ssl
--threads:on
@if macosx:
  # pending bug #15019 
  -d:useStdlib
@end

@ghost
Copy link

ghost commented Jul 22, 2020

Thanks @Araq and @dom96

This is a small app that is meant to always be running on your machine, and regularly crawl html websites and rss feeds, and import records into a sqlite database. A self-hosted torrent search engine.

https://github.com/sergiotapia/torrentinim

@ghost ghost added the Async Everything related to Nim's async label Jul 26, 2020
@ghost
Copy link

ghost commented Feb 9, 2021

Hi @Yardanico was this ever fixed? Coming back to my app now and using Nim 1.4.2. Should I remove the -d:useStdlib? thanks for the info

@metagn
Copy link
Collaborator

metagn commented Aug 28, 2023

Supposedly problem was with httpbeast, async-check repository linked in issue gives not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Async Everything related to Nim's async Waiting on Author
Projects
None yet
Development

No branches or pull requests

6 participants