Help needed: Deadlock during allocShared0

2021-02-04 Thread leorize
Yea but it's still using `add()`, which may grow the string.

Help needed: Deadlock during allocShared0

2021-02-04 Thread boia01
Thanks for all the replies! This helps a lot. I had a suspicion the signal handler was trying to print a stack trace. Per @leorize' and @shirleyquirk's comments, it seems I stumbled on a stdlib bug. Should I file a bug report? I'll try `c_malloc` to try to work around the issue and better unders

Help needed: Deadlock during allocShared0

2021-02-04 Thread shirleyquirk
so signalHandler shouldn't be doing [this](https://github.com/nim-lang/Nim/blob/bb1c962286922487c5243ca7304fd95fdd27ea53/lib/system/excpt.nim#L636) ? + var buf{.global.} = newStringOfCap(2000) - var buf = newStringOfCap(2000) Run

Help needed: Deadlock during allocShared0

2021-02-04 Thread leorize
The bug is the attempt to allocate memory in an asynchronous signal handler... Signal handlers are like threads but spawned at random points while pausing the thread it's running on. Most code are not and cannot handle this stuff, which is totally understandable. POSIX has a strict definition of

Help needed: Deadlock during allocShared0

2021-02-04 Thread mratsim
When I tried Weave with allocShared I had deadlocks as well and I didn't use signals. For multithreaded application, I suggest you create your own allocator wrapper that allow you to toggle betwen Nim allocator and malloc.

Help needed: Deadlock during allocShared0

2021-02-04 Thread shirleyquirk
It's [this signal handler](https://github.com/nim-lang/Nim/blob/bb1c962286922487c5243ca7304fd95fdd27ea53/lib/system/excpt.nim#L612) that tries to print out a stack trace, but can't alloc the new string.

Help needed: Deadlock during allocShared0

2021-02-03 Thread boia01
@leorize It's not my signal handler. It must be one of Nim's default.

Help needed: Deadlock during allocShared0

2021-02-03 Thread leorize
Are you allocating any memory in the signal handler? If you do, that's the problem.

Help needed: Deadlock during allocShared0

2021-02-03 Thread boia01
Hi folks, I have a multi-threaded application that deadlocks during processing. The deadlock involves Nim's own allocator, through `allocShared0`. One weird thing is that it only seems to happens when a signal handler is called during allocation, see stack entry #6 below: [Switchi