Issue 128589 - Crash if use EnumableMap put method embed in a function
Summary: Crash if use EnumableMap put method embed in a function
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 4.1.15
Hardware: All All
: P5 (lowest) Normal
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2024-02-02 12:44 UTC by oooforum (fr)
Modified: 2024-02-02 17:39 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.2.0-dev
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description oooforum (fr) 2024-02-02 12:44:24 UTC
This code works:
Sub Main
	oVar = com.sun.star.container.EnumerableMap.create("string", "string")
	oVar.put("Foo","")
	oVar.put("Bar","")
End Sub

So now, I create 2 functions to embed .put method and check if key exists
Warning, this code crashed AOO:
Sub Main
	oVar = com.sun.star.container.EnumerableMap.create("string", "string")
	EnumAddKey(oVar, "Foo")
	EnumAddKey(oVar, "Bar")
End Sub

Function EnumAddKey(oTmp, sTmp)
	if EnumCheckKey(oTmp, sTmp) then 
		msgbox "Key already exists: " & sTmp
		exit function
	endif
	oTmp.put(sTmp, "")
	EnumAddKey = oTmp
End function

Function EnumCheckKey(oTmp, sTmp)
	sRet = false
	oEnum = oTmp.createKeyEnumeration(False)
	Do While oEnum.hasMoreElements
		sItem = oEnum.nextElement
		if sTmp = sItem then sRet = true : exit do
	Loop
	EnumCheckKey = sRet
End function


It failed on second EnumAddKey function call in oTmp.put line for no reason

Tested on Debian and Win10 with same (bad) result.
Comment 1 damjan 2024-02-02 15:45:57 UTC
Works perfectly here, on FreeBSD 14.0, AOO trunk at commit f772f8bcada2271f2a87d325fb11fb21c8a19b20, debug build.

Also works fine on FreeBSD with:
- an older version of AOO trunk, debug build.
- f331e23ffae9e26f93997dc8f02086c5733e80df (the merge base between trunk and 4.1.x) from 2014-02-25, debug build.

But crashes on:
- 4e549649559c9592d2292549945507e18df42348 from 2018-01-04, Windows build on Wine on FreeBSD, release build.
- 71bc2237ed32a770b27c542d9e9f101134b193a4 from 2017-07-01, Windows build on Wine on FreeBSD, release build.
- f9124e1e1a8486de2fb603f628b652a5ff012fd6 from 2015-11-25, Windows build on Wine on FreeBSD, release build.

So do debug builds work while release builds crash, or is FreeBSD particularly immune to crashes for some reason?
Comment 2 Matthias Seidel 2024-02-02 16:21:32 UTC
Can you please try with our AOO420-dev5 build:

https://dist.apache.org/repos/dist/dev/openoffice/4.2.0-Dev5/
Comment 3 damjan 2024-02-02 17:02:46 UTC
(In reply to Matthias Seidel from comment #2)
> Can you please try with our AOO420-dev5 build:
> 
> https://dist.apache.org/repos/dist/dev/openoffice/4.2.0-Dev5/

This crashes too :-(.
Comment 4 Matthias Seidel 2024-02-02 17:06:19 UTC
(In reply to damjan from comment #3)
> (In reply to Matthias Seidel from comment #2)
> > Can you please try with our AOO420-dev5 build:
> > 
> > https://dist.apache.org/repos/dist/dev/openoffice/4.2.0-Dev5/
> 
> This crashes too :-(.

OK, Windows and Linux?
Comment 5 damjan 2024-02-02 17:39:04 UTC
(In reply to Matthias Seidel from comment #4)
> (In reply to damjan from comment #3)
> > (In reply to Matthias Seidel from comment #2)
> > > Can you please try with our AOO420-dev5 build:
> > > 
> > > https://dist.apache.org/repos/dist/dev/openoffice/4.2.0-Dev5/
> > 
> > This crashes too :-(.
> 
> OK, Windows and Linux?

Windows crashes. Xubuntu 23.04 works - I only get a crash later, when exiting, in a Bitmap destructor in vcl, probably unrelated to this bug.