go-sciter
go-sciter copied to clipboard
fatal error: concurrent map read and map write
Fisrt,I bind click event to the element after SetHtml() code. Then I trigger the click event. After that,the issue show like this:
sciter.go:600
How can I fix it?
Do you use goroutines or threads?
@pravic I did not. I did the things like these: 1、call SetHtml() function to change the element 2、bind the click event to the element 3、trigger the click event 4、when i trigger the click event,I will back to step 1 and step by step
I did these things many a time,then the issue showed.
Well, then it's really odd, because Sciter itself runs in a single UI thread, and so do its events that are bound to Go's handlers.
Is it possible to make a minimal code example with this issue?
I make the example like this:
When I use multiple strings to the SetHtml function,and bind the event after setter the issue may be showed. I think the reason is when the event try to bind to the element ,the html did not load complete. But I do not know how to fix it. Did the SetHtml function has the onLoaded event?
Oh dear, it'd be really a challenge to OCR your screens.
Did the SetHtml function has the onLoaded event?
It can be the CONTENT_CHANGED
event.
@c-smile Andrew, could you comment on this issue?
When that finalize
function is called? What code initiates its call?
It's called by GC, because of runtime.SetFinalizer
, which is registered here:
https://github.com/sciter-sdk/go-sciter/blob/83bc269d88dd706b394eb591ff2702ce93c8eb61/sciter.go#L558-L566
Also its documentations says
A single goroutine runs all finalizers for a program, sequentially.
So it looks like a go-sciter's issue. Perhaps. Because it's never occurred before.
@ibenben Your Go version, by the way?
@pravic My Go version is 1.11 .
The CONTENT_CHANGED event did not fix the issue. I need some help. @pravic
When I use multiple strings to the SetHtml function,and I do not bind the event after setter the issue may also be showed.
Nice try.
This:
html = "A";
for( i = 0; i < 20; ++i )
html += html;
will be a string of length 220
And your code above will try to allocate string of size 4020.
Correction not 4020 but 40 * 220 which is way smaller but still quite large for reasonable HTML - 41,943,040 Mb.
Are we in Halloween contest? Or is this normal, everyday thing in Goland?
The length of html string in my code is 52428800. Golang permits it.
That is a try.But my issue does not be fixed.
Before the issue is showed,the html string can be loaded. I need some help. @c-smile
I am sorry to bother you. Happy Halloween.
Golang permits it.
Oh, really? I suspected that google is the only place where magicians still live these days. But even for them to allocate memory chunk of size 1032 could be challenging.
Just for the note number of atoms in Universe is 1078.
In any case it is not clear who will consume HTML of 52 MB in size.
Just for the note: number of words in "War and Peace" of Leo Tolstoy is 587,287. That will be around 5 MB of characters. User will throw away your app if your show that amount of data to him/her.
So what's the point?