-
Notifications
You must be signed in to change notification settings - Fork 64
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
Doesn't work in anon thread #390
Comments
I guess you do something wrong. Show the primitive demo to repeat the error. I dont have Delphi, i have FPC. |
Hello, I didn’t even expect you to answer so quickly, here’s a simple code that demonstrates the problem:
If you remove the wrapper TThread.CreateAnonymousThread then everything works ! |
I also tested with omnithreadlibrary and wrapped it in CreateTask instead of TThread.CreateAnonymousThread, the problem is also there |
Anon functions require fpc 3.3, i dont have it. Maybe will install it. Pls use triple quotes for code block, ie markdown fenced block. |
Try using omnithreadlibrary CreateTask, this problem also exists there ! |
By the way, for some reason this error also occurs with the standard library System.RegularExpressions:
The same thing, if you remove the TThread.CreateAnonymousThread wrapper, then everything works ! |
@User4martin Can you reproduce it under fpc, please? |
Sorry I don't have FPC =( |
Hi, it worked like this:
The problem is that synchronization freezes the form and there is no point in such code |
will check in a couple of days.... |
If you get a range check, then you should be able to get a stacktrace? Also the error sounds (I have not checked) like it is thrown be the thread. You could single step the code, and check if the issue happens while reading the thread, or while running regex. The synchronize may or may not be a coincidence. It might be just hiding the issue (or not).... I also have to check what happens if you pass an "array of char" to a string param. Or rather when you "+" join it with the ReadLine. Especially, if maybe the prior read did not fill the entire array. Have you checked in the debugger, if the content of the string "text" in "pars" is what you expect? |
Yes, if you read TStreamReader.ReadLine on one line, then no error occurs, the error occurs only when reading with a buffer TStreamReader.Readblock or TStreamReader.Read |
As if it wants to work like this, it displays the first lines, but still closes immediately:
|
I don't have Delphi either, and I can't compile the code. But I searched TRegExpr for the error So you either have an older version (and it is unknown if the error actually still exists), or the error happens somewhere else. |
Sounds like you run modified code to test that => that does not help. What happens when you
Can you step into to the line If yes, then what is the stacktrace in TRegExpr? Also: Are you testing with the latest version of TRegExpr? Have you downloaded it from this GitHub repo? (In or after July 2024?) |
I moved the buffer to a global variable and the program worked ! const var ...... The only problem is that the buffer will probably need to be cleaned in a loop =) |
Non of the "workarounds" you described should affect the TRegExpr code, as you are calling it with Also seeing how your seemingly random changes hide the issue, I am certain it likely in TStreamReader (or the way you call it). Or maybe (though I find it unlikely) in the fact that your param is "const" (I don't know how exactly the nitty gritty of this this is implemented in Delphi...,) Btw... Anyway, as I said: I do not have Delphi, I can not help you further on the TStreamReader related points above. If (and 99% likely: only if) you
Only then may I be able to help further. Unfortunately, otherwise I do not have the means to find the issue. About your modified versions => all of those code modifications that you made can have any number of unknown side effects (and those may be very specific to the exact Version of Delphi that you use). So I have no way to know how, why the "hide" the issue. Therefore they do not in any way tell me where exactly the issue is. |
Hi TRegEXpr does not work in conjunction with TstreamReader in a thread
TThread.CreateAnonymousThread(
procedure begin
.....
I get a buffer overflow error: Exception class ERangeError with message 'Input buffer exceeded for DestinationIndex = 0, Count = 18432'
The text was updated successfully, but these errors were encountered: