<FromGitter>
<mattrberry> @oprypin:matrix.org Offset by one int? I just tested and I have to offset the SDL::Event pointer by 2 ints in order to get the expected value Could this be some difference between systems? Is there documentation on how crystal lays out its memory?
Vexatos has quit [Read error: Connection reset by peer]
Vexatos_ has joined #crystal-lang
markmarkmark has quit [Ping timeout: 272 seconds]
markmarkmark has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
Guest97 has joined #crystal-lang
Guest97 has quit [Ping timeout: 250 seconds]
<FromGitter>
<Blacksmoke16> is there a naming convention related to when a setter has more than 1 arg? E.g. `def default_command(name : String, single_command : Bool = false)` versus `def set_default_command(name : String, single_command : Bool = false)`
<FromGitter>
<naqvis> AFAIK crystal doesn't make use of `get_`, `set_`
<FromGitter>
<naqvis> i mean conventionally
Guest97 has joined #crystal-lang
Guest97 has quit [Client Quit]
Guest49 has joined #crystal-lang
<FromGitter>
<Dan-Do> at runtime, is there any way to show stats of running fiber?
<FromGitter>
<Dan-Do> I want to know which fiber is blocking the main thread
<FromGitter>
<naqvis> your code is not the one creating the fibers?
<FromGitter>
<Dan-Do> no, I don't create any fiber. I am using many shards like kemal, db, html5 (yours :))... so I am not sure
<FromGitter>
<naqvis> I haven't tested this, but guess you can have that extension code (in above forum link) and then somewhere in your code you can try to invoke ⏎ `Fiber.current.print_backtrace` and see if it works for you
sorcus has quit [Ping timeout: 244 seconds]
sorcus has joined #crystal-lang
<FromGitter>
<Dan-Do> It returns `running, unable to get backtrace`
deavmi has quit [Read error: Connection reset by peer]
<FromGitter>
<naqvis> so in summary, just use the extension code in forum post and then run ⏎ `Fiber.unsafe_each {|f| pp f, f.print_backtrace}` do get backtrace of all fibers
<FromGitter>
<Dan-Do> yeah, just found that :)
<FromGitter>
<naqvis> 👍
dom96 has quit [Ping timeout: 272 seconds]
dom96 has joined #crystal-lang
arestifo has joined #crystal-lang
hightower2 has joined #crystal-lang
hightower2 has quit [Ping timeout: 264 seconds]
<FromGitter>
<mattrberry> Hey @oprypin I know you've worked with this before so maybe you know a bit more. Since cimgui builds a shared object file, is there any way for me to link that without setting the LD_LIBRARY_PATH? Ideally any project that wanted to use crystal-imgui-backends could just put it in the shard.yml and not have to think about it any further. I already have the postinstall script building everything, but then I
<FromGitter>
... currently still need to set LD_LIBRARY_PATH so that it can link at runtime
deavmi has quit [Ping timeout: 272 seconds]
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
deavmi has joined #crystal-lang
hightower3 has joined #crystal-lang
arestifo has joined #crystal-lang
hightower3 has quit [Ping timeout: 252 seconds]
Guest49 has joined #crystal-lang
<FromGitter>
<Blacksmoke16> @naqvis I guess my thinking is should it use `set_` in this context to make it more clear it's a setter versus a getter with args? Or does have the option required argument make that clear enough
<FromGitter>
<naqvis> yeah agree having clear and concise name removes the ambiguity and make the intention clear. But I was talking about crystal conventions of not using such naming style to highlight the purpose of the method. Just did a quick search in api for methods starting with `set_` and there are very few 14 or so, and majority of them are part of FFI related stuff
<FromGitter>
<naqvis> but, if method name make things more clear, I will definitely go with using the name which make things more obvious to its users
Guest49 has quit [Ping timeout: 250 seconds]
<FromGitter>
<Blacksmoke16> heres an example, which do you like better?
<FromGitter>
<naqvis> first one is obvious enough, so I'll go with that
<FromGitter>
<naqvis> because method in that context is making things clear that its setting XXXX
<FromGitter>
<Blacksmoke16> 👍 cool, because that's what i went with
<FromGitter>
<Blacksmoke16> imma just go with it, always can deprecate them in favor of something else later on. But this is fine for initial implementation
Guest49 has joined #crystal-lang
<FromGitter>
<naqvis> 👍
Guest49 has quit [Client Quit]
jhass[m] has quit [Quit: node-irc says goodbye]
jcs has joined #crystal-lang
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arestifo has joined #crystal-lang
<FromGitter>
<Dan-Do> in mt mode, why `@ivar` of difference instances is shared and overwritten by fibers?
<FromGitter>
<erdnaxeli:cervoi.se> it should probably not. Do you have some code to show this behavior?
<FromGitter>
<Dan-Do> without MT, the result is correct. When built with MT, it's wrong
<FromGitter>
<naqvis> might be you writing to console is getting switched between fibers, thus giving you feelings of its being overwritten
<FromGitter>
<Dan-Do> just an example, real code return the `@result, @code` to http response to browser
<FromGitter>
<naqvis> suppose you have two fibers F1, F2, F1 writing to console some output and then get scheduled out due to IO , F2 get its turn and start writing to console
<FromGitter>
<erdnaxeli:cervoi.se> yes, you should trying to return the result instead
<FromGitter>
<wyhaines> @ddd It's the same answer to this question as to all of them that you have asked for the last several days. ⏎ ⏎ If you are using threads, you either *can not* share state, or you *must* synchronize the use of shared state. ⏎ ⏎ Either use channels to communicate between your threads, and don't share anything, or use a Mutex to syncrhonize the access to shared state. ...
<FromGitter>
<Dan-Do> I debug this issue several days but don't know how to solve
<FromGitter>
<Blacksmoke16> whats the problem exactly? you're seeing things get printed to your console out of order? Is the actual response body correct?
<FromGitter>
<Dan-Do> No, I return json to broswer `{"result": r.result, "count": r.count}.to_json`
<FromGitter>
<wyhaines> "in mt mode, why `@ivar` of difference instances is shared and overwritten by fibers?" ⏎ ⏎ If that is actually happening, then there is shared state. In the example from last week where it superficially looked like variables were getting changed in a strange when when running MT, what was really happening was just that the diagnostic output to the screen was getting mixed by parallel threads. ⏎ ⏎
<FromGitter>
... Without complete context, I can't say where the shared state exists this time, but if one fiber is overwriting the value of an instance variable in unexpected ways, that is because the access to that instance variable is shared, and unsynchronized. [https://gitter.im/crystal-lang/crystal?at=60be33640f247f448ea231e8]
<FromGitter>
<Blacksmoke16> > No, I return json to broswer `{"result": r.result, "count": r.count}.to_json` ⏎ ⏎ So what's the problem?
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<erdnaxeli:cervoi.se> do you have a fully working example showing the bug?
<FromGitter>
<Dan-Do> @wyhaines @erdnaxeli:cervoi.se Thanks, I will look at the code more carefully to find the shared vars
<FromGitter>
<wyhaines> @erdnaxeli:cervoi.se Add a short sleep into your *#execute*, to simulate waiting on some IO. `sleep(rand)` is sufficient. And then hit the kemal server with a number of concurrent requests. I would bet that there are parts of Kemal that are not threadsafe.
<FromGitter>
<wyhaines> I mean, there are common parts of the stdlib that are not threadsafe, so it's almost certain that kemal has some threadsafety issues, too.
<FromGitter>
<erdnaxeli:cervoi.se> hmm I still don't see responses with invalid values, but my test is only `while true; do curl localhost:3000/person & done`
<FromGitter>
<wyhaines> Yeah. So that is itself sequential.
<FromGitter>
<Dan-Do> @erdnaxeli:cervoi.se Can you try wrk to open multiple threads?
<FromGitter>
<Dan-Do> but I don't think your code would raise that issue :)
<FromGitter>
<erdnaxeli:cervoi.se> it is concurrent, I ran 2k curl during some seconds
<FromGitter>
<erdnaxeli:cervoi.se> so you need to find some code that raises the issue
<FromGitter>
<Dan-Do> like @wyhaines said, there must by shared vars somewhere
<FromGitter>
<erdnaxeli:cervoi.se> yeah I'm sure too :)
jhass[m] has joined #crystal-lang
arestifo has joined #crystal-lang
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
arestifo has joined #crystal-lang
<FromGitter>
<Dan-Do> Does the different IO (of TCPSocket) have different file descriptor?
<FromGitter>
<wyhaines> This is the hard thing about multithreaded programming. One doesn't have to look very far to find examples of shared state. Even in ubiquitous code like the Hash implementation, if you have two threads which are assigning to the same hash at the same time, they can stomp on each other in bad ways. ⏎ ⏎ And I'm sure that the HTTP Server implementation in the stdlib isn't thread safe, so there is definitely
<FromGitter>
<Dan-Do> I am looking forward to seeing that
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<rishavs> What is a simple way to get the request params coded in the requets body (eg for POST requests)? ⏎ Currently I am using a model class with a JSON:Serializable attribute but its overkill for my usecase ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60be533f1477ff6954a6ffc8]
<FromGitter>
<Blacksmoke16> i.e. you want to switch from json data to form data?
<FromGitter>
<rishavs> No. I still want to use request body for the payload. But was wondering if I have to use a JSON serializable approach to get this payload
<FromGitter>
<Blacksmoke16> as opposed to what?
<FromGitter>
<Blacksmoke16> `JSON.parse`?
<FromGitter>
<Blacksmoke16> you already have the request body contents, `body.try &.gets_to_end`
<FromGitter>
<rishavs> i know. Was thinking we may have a convenience method around this 😅
<FromGitter>
<Blacksmoke16> nope
<FromGitter>
<Blacksmoke16> could do something like this tho
<FromGitter>
<rishavs> Thanks! I was thinking of getting rid of the classes as I don use the typical "models" in my code. But I guess it is indeed the proper way of doing things. 👍
<FromGitter>
<Blacksmoke16> er, backing up. What are you doing with the `req` object here/
<FromGitter>
<Blacksmoke16> like just using it as a means to access the data, or also doing like `req.password = ...`?
<FromGitter>
<rishavs> just to access the data. after that i never touch that class
<FromGitter>
<Blacksmoke16> ok, then yea, using a record will be perfect
<FromGitter>
<Blacksmoke16> how are you handling validation of the data?
<yxhuvud>
@straight-shoota: regarding that ci error, have you verified that things like stacktraces from spawned fibers are printing like they should? Lots of what you are doing is happening in between fibers after all.
<straight-shoota>
at this point there is no fiber switching involved
<straight-shoota>
it happens all in the main fiber: issue an operation, wait for it to finish, collect the completed result
<yxhuvud>
Have you tried putting a rescue where it seems to fail and print what you get?
<yxhuvud>
that of course requires finding the place which may be nontrivial.
<straight-shoota>
exactly that is the problem
<straight-shoota>
=)
<straight-shoota>
I'll probably have to put in a series of puts beacons
<yxhuvud>
yes, except it is not obvious you can trust puts to work. Crystal::System.print_error is the way to go :)
<straight-shoota>
probably better, yes
<yxhuvud>
I've literally had unrelated tests fail *because* I used puts in some places.
<straight-shoota>
o_o
<yxhuvud>
it turned out io_uring didn't support writing to STDOUT in versions < 5.8. oops.
<yxhuvud>
so I only got EAGAIN.
Guest7 has joined #crystal-lang
Guest7 has quit [Client Quit]
<yxhuvud>
and I had only a test on write, not on writing to stdout in particular.
riza has joined #crystal-lang
sorcus has quit [Quit: WeeChat 3.1]
<riza>
hey hey crystal made it on the list of Stack Overflow questions
sorcus has joined #crystal-lang
Guest13 has joined #crystal-lang
Guest13 has quit [Client Quit]
<FromGitter>
<Daniel-Worrall> Wan't it already?
Guest17 has joined #crystal-lang
<riza>
it wasn't last year, I had to write it in
<FromGitter>
<oprypin:matrix.org> i think this is talking about their yearly usage survey
Guest17 has quit [Quit: Client closed]
<riza>
that's right, sorry.
Guest936 has joined #crystal-lang
<Guest936>
Wow star studded chat, its got some big contributors, thank you for crystal it's super sweet, bye y'all!