Hello I use some macros (VBA) from Excel and build it into LibreOffice-Calc into the macro. The macro contains the following code: -------------------- 'Replace the character with spaces Mid (S1, P1) = " " -------------------- Mid (S1, P1) = " " <---- This generated a Program-Crach. (Reproducible) This is taken over from Excel (VBA) This function works in VBA With Mid (S1, P1,1) = " " The error could be fixed. Only should not synonymous generate a program crash, but only a syntax error. Is contained in the following code: ----------- 'Any characters that can not be contained in the string with Blank 'Alle Zeichen, die nicht im String enthalten sein dürfen, mit Blank erseten For P1 = 1 To Len(S1) Select Case Asc(Mid(S1, P1, 1)) 'alle zulässigen behalten Case 78, 69, 83, 87, 44, 46, 32 ' N E S W , . leer 'Nichts machen Case 48 To 57 'sind Zahlen 'Nichts machen Case 45 'ist Minuszeichen 'Nichts machen Case Else 'Das Zeichen ersetzen mit Leerzeichen 'Mid(S1, P1) = " " '<-- generated a Program-Crash 'Erzeugt einen Programmabsturtz Mid(S1, P1,1) = " " '<-- The error could be fixed. 'Fehler behoben End Select Next
Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided. (Please note that the attachment will be public, remove any sensitive information before attaching it. See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Dear Bug Submitter, This bug has been in NEEDINFO status with no change for at least 6 months. Please provide the requested information as soon as possible and mark the bug as UNCONFIRMED. Due to regular bug tracker maintenance, if the bug is still in NEEDINFO status with no change in 30 days the QA team will close the bug as INSUFFICIENTDATA due to lack of needed information. For more information about our NEEDINFO policy please read the wiki located here: https://wiki.documentfoundation.org/QA/Bugzilla/Fields/Status/NEEDINFO If you have already provided the requested information, please mark the bug as UNCONFIRMED so that the QA team knows that the bug is ready to be confirmed. Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-NeedInfo-Ping-20180302
Dear Bug Submitter, Please read this message in its entirety before proceeding. Your bug report is being closed as INSUFFICIENTDATA due to inactivity and a lack of information which is needed in order to accurately reproduce and confirm the problem. We encourage you to retest your bug against the latest release. If the issue is still present in the latest stable release, we need the following information (please ignore any that you've already provided): a) Provide details of your system including your operating system and the latest version of LibreOffice that you have confirmed the bug to be present b) Provide easy to reproduce steps – the simpler the better c) Provide any test case(s) which will help us confirm the problem d) Provide screenshots of the problem if you think it might help e) Read all comments and provide any requested information Once all of this is done, please set the bug back to UNCONFIRMED and we will attempt to reproduce the issue. Please do not: a) respond via email b) update the version field in the bug or any of the other details on the top section of our bug tracker Warm Regards, QA Team MassPing-NeedInfo-20180404
Created attachment 141089 [details] Reproducible document Run Main() When I run the macro with my own local build, an assertion error happens at https://opengrok.libreoffice.org/xref/core/sal/rtl/ustrbuf.cxx?r=5a3bb76c#237 I'm not going to write a patch myself this time(I'm tackling on another issue right now)
marking this as NEW
Regression introduced by: author Stephan Bergmann <sbergman@redhat.com> 2014-11-20 08:23:53 +0100 committer Stephan Bergmann <sbergman@redhat.com> 2014-11-20 08:34:07 +0100 commit 04ae3d0cc9b671729deabf33c2cea1031d72e6ae (patch) tree 5b3b8f08aa393c8e659947bd709f3752299686f2 parent e7abad5683a28305204977b57357dddefab0e065 (diff) len cannot be <= 1 here Bisected with: bibisect-44max Adding Cc: to Stephan Bergmann
@Stephan, it seems this change avoids the crash: --- a/sal/rtl/ustrbuf.cxx +++ b/sal/rtl/ustrbuf.cxx @@ -154,7 +154,7 @@ void SAL_CALL rtl_uStringbuffer_insert( rtl_uString ** This, if( len == 1 ) /* optimized for 1 character */ pBuf[offset] = *str; - else + else if( len > 1 ) memcpy( pBuf + offset, str, len * sizeof(sal_Unicode) ); } (*This)->length = nOldLen + len;
(In reply to Xisco Faulí from comment #6) > Regression introduced by: > > author Stephan Bergmann <sbergman@redhat.com> 2014-11-20 08:23:53 +0100 > committer Stephan Bergmann <sbergman@redhat.com> 2014-11-20 08:34:07 +0100 > commit 04ae3d0cc9b671729deabf33c2cea1031d72e6ae (patch) > tree 5b3b8f08aa393c8e659947bd709f3752299686f2 > parent e7abad5683a28305204977b57357dddefab0e065 (diff) > len cannot be <= 1 here That commit is merely adding the assert that fires here because SbRtl_Mid (basic/source/runtime/methods.cxx) is calling rtl::OUStringBuffer::remove with bad arguments (*this being "abc", start=0, len=-1).
Stephan Bergmann committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=cc20344010e94eda22fee662aab966d395a0796a tdf#111313: Honor bWriteNoLenParam in !bCompatibility, too It will be available in 6.1.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Verified in Version: 6.1.0.0.alpha0+ Build ID: 0a4c1fb68c3619e61099a7c548f550b0d3fd7a53 CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk3; Locale: ca-ES (ca_ES.UTF-8); Calc: group Stephan, Thanks for fixing this.
Should it be backported to 6-0?
(In reply to Xisco Faulí from comment #11) > Should it be backported to 6-0? I wasn't sure. For one, I'm not entirely sure what the indented difference of the (non-)compatibility modes in e8deba22e887a972f60ff05551e93c334ac1e7b6 "INTEGRATION: CWS ab26" was, and whether my change is actually faithful to that. For another, the issue has been present for so long (even inherited from OOo in its original form, merely made more severe by tighter argument checking of the rtl string functions in later versions of LO) that I don't see a need to rush in a (potentially brittle) fix. But I wouldn't oppose a backport either, if others see a need.
Xisco Fauli committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/0ce3a9dcc071094121252a286aa88529ee09a4eb tdf#111313: basic_macros: Add unittest It will be available in 7.3.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
I'm giving a try at tdf#126913 with a straightforward patch: diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 17b6092a3278..04d1645f4ccb 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1092,6 +1092,8 @@ void SbRtl_LTrim(StarBASIC *, SbxArray & rPar, bool) void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite) { + // Beware, format of Mid is: Mid(stringvar, start, [ length ] ) = string + // if "string" is provided, nArgCount is always = 4 even if "length" isn't provided int nArgCount = rPar.Count() - 1; if ( nArgCount < 2 ) { @@ -1147,7 +1149,7 @@ void SbRtl_Mid(StarBASIC *, SbxArray & rPar, bool bWrite) sal_Int32 nReplaceLen; if( bWriteNoLenParam ) { - nReplaceLen = nArgLen - nStartPos; + nReplaceLen = std::min(nReplaceStrLen, aArgStr.getLength() - nStartPos); } else { Xisco: are you sure about test_tdf111313.bas I mean when doing: s = "abc" Mid(s,1) = "d" shouldn't it return: "dbc" ? Since the replace string is 1 character long, why removing "bc" ? Reading https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/mid-statement Part Description stringvar Required. Name of string variable to modify. start Required; Variant (Long). Character position in stringvar where the replacement of text begins. length Optional; Variant (Long). Number of characters to replace. If omitted, all of string is used. string Required. String expression that replaces part of stringvar.