Closed
Bug 547935
Opened 15 years ago
Closed 15 years ago
Initialization of PCREContext leads to crash on Symbian emulator without EPOCALLOWDLLDATA
Categories
(Tamarin Graveyard :: Virtual Machine, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
flash10.2.x-Spicy
People
(Reporter: kenichia, Assigned: lhansen)
References
Details
(Whiteboard: has-patch)
Attachments
(1 file, 3 obsolete files)
3.95 KB,
patch
|
stejohns
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2) Gecko/20100115 Firefox/3.6 GTBDFff GTB7.0 (.NET CLR 3.5.30729)
Build Identifier:
There is the following static variable in the global scope in AVMCore.cpp.
static GCThreadLocal<Toplevel*> PCREContext;
This PCREContext is treated as a Writable Static Data(WSD) on Symbian OS. Also Symbian emulator has the following restriction on WSD.
"The only restriction is that if the data’s initialisers call any Symbian OS kernel functions (i.e. executive calls) the emulator will fault."
Reference:
http://developer.symbian.org/wiki/index.php/Symbian_Platform_Support_for_Writeable_Static_Data_in_DLLs
Since AVM calls pthread_key_create, which is a kernel function, from the static_initializer, the emulator crashes because of the above restriction.
Reproducible: Always
Steps to Reproduce:
1. Launch VM.
2. PCREContext is created in the initialization process, because it's a global static variable.
3. The constructor of MMgc::GCThreadLocal is invoked, then it calls VMPI_tlsCreate and pthread_key_create.
Actual Results:
Crashes due to "FAULT: BAD DLL STATIC 0x00000000 (0)"
Backtrace:
27 VMPI_tlsCreate() ...\VMPI\ThreadsPosix.cpp:45 0x47c9820d
26 MMgc::GCThreadLocal<avmplus::Toplevel *>::GCThreadLocal() ...\MMgc\GCThreadLocal.h:52 0x47deb537
25 $static_initializer$415() ...\MMgc\WriteBarrier.h:279 0x47deb49d
24 invokeTable() Z:\src\cedar\generic\base\e32\include\win32crt.h:119 0x47c976c3
23 _E32Dll() Z:\src\cedar\generic\base\e32\euser\epoc\win32\uc_dll.cpp:60 0x47c97964
Expected Results:
No crash
Made a patch for this bug. Changed GCThreadLocal.h.
Applying "lazy initialization" pattern to MMgc::GCThreadLocal solves this problem, because the constructor of GCThreadLocal does not call a kernel function(pthread_key_create) in the initialization process.
Reporter | ||
Comment 1•15 years ago
|
||
Reporter | ||
Comment 2•15 years ago
|
||
Attachment #428391 -
Attachment is obsolete: true
Reporter | ||
Updated•15 years ago
|
Severity: critical → normal
OS: Other → Symbian
Assignee | ||
Updated•15 years ago
|
Attachment #428396 -
Flags: review?(lhansen)
Assignee | ||
Comment 3•15 years ago
|
||
Comment on attachment 428396 [details] [diff] [review]
proposed patch - GCThreadLocal.h diff
Patch rejected because:
- the patch introduces a race condition in the initialization of that global variable, the purpose of having them static globals is for the initialization to be executed on the main thread always.
- returning NULL when the thread local is not valid is wrong for several reasons, notably because the T is not always a type that has NULL in its value set and because the consequence of returning NULL for the -> operator is an immediate crash.
- the patch is incorrect, it shows the new code as being removed rather than added.
Also, I don't know if we're inclined to work around bugs in the Symbian emulator, but we'll have to discuss that.
Attachment #428396 -
Flags: review?(lhansen) → review-
Comment 4•15 years ago
|
||
This patch is to work around an issue, that only one process (a time) can load Flash dll successfully in the Symbian emulator. Multiple processes can load Flash dll in device without problems.
An example: the first process can be a browser, the second some other user application, like desktop widget. Flash/FlashLite can be used in Symbian desktop widgets.
Reporter | ||
Comment 5•15 years ago
|
||
Hi Lars, thanks for the review.
As Samuli mentioned the above, some customer who develops a product on Symbian ran into this issue. Since this is a serious problem for them, they requested us to fix this issue. They also claims that the AVM worked on the Symbian emulator before introducing PCREContext variable.
What Symbian emulator can't do is to call kernel functions from the initialization of writable global (static) variables.
That's why I moved the code from the constructor to the other functions. But now that I understand this patch has some problems, we have to find other work around.
Assignee: nobody → skekki
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: flashplayer-qrb+
Priority: -- → P2
Target Milestone: --- → flash10.1
Comment 6•15 years ago
|
||
Is there a way to determine (either compiletime or runtime) that we are targeting the emulator?
Comment 7•15 years ago
|
||
Sure, in the current emulator you can check for __WINSCW__ at compile time. Not sure about runtime check.
Comment 8•15 years ago
|
||
These would fix the problem: make PCREContext constructor not call any VMPI function or make PCREContext a non-static variable. Not sure it the vm team can consider these.
Comment 9•15 years ago
|
||
(In reply to comment #8)
> These would fix the problem: make PCREContext constructor not call any VMPI
> function or make PCREContext a non-static variable. Not sure it the vm team can
> consider these.
What if we made PCREContext non-static, but only ifdef __WINSCW__? Then all other existing targets would be unaffected.
Assignee | ||
Comment 10•15 years ago
|
||
(In reply to comment #9)
> (In reply to comment #8)
> > These would fix the problem: make PCREContext constructor not call any VMPI
> > function or make PCREContext a non-static variable. Not sure it the vm team can
> > consider these.
>
> What if we made PCREContext non-static, but only ifdef __WINSCW__? Then all
> other existing targets would be unaffected.
Only if you're sure that it'll be created by the main thread before any other threads get created, or you have a race condition on the creation (which is the main reason why it was static to begin with).
Comment 11•15 years ago
|
||
Hi Lars, could you tell more about the race condition and why it is important that the main thread creates PCREContext. What are the other threads you refer to? Isn't avm single threaded?
Comment 12•15 years ago
|
||
= single threaded in the context of Flash Player
Updated•15 years ago
|
Target Milestone: flash10.1 → flash10.1.1
Comment 13•15 years ago
|
||
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > These would fix the problem: make PCREContext constructor not call any VMPI
> > > function or make PCREContext a non-static variable. Not sure it the vm team can
> > > consider these.
> >
> > What if we made PCREContext non-static, but only ifdef __WINSCW__? Then all
> > other existing targets would be unaffected.
> Only if you're sure that it'll be created by the main thread before any other
> threads get created, or you have a race condition on the creation (which is the
> main reason why it was static to begin with).
Comment 14•15 years ago
|
||
Comment on attachment 428396 [details] [diff] [review]
proposed patch - GCThreadLocal.h diff
A new patch coming
Attachment #428396 -
Attachment is obsolete: true
Comment 15•15 years ago
|
||
This change was approved by Steven for FP earlier. Please take a look if it's good enough for Tamarin as is or if you need any changes.
Attachment #440254 -
Flags: review?(stejohns)
Comment 16•15 years ago
|
||
I can see some } difficulties that I don't see in my code editor. Do you want a net patch or could you fix this locally before submitting?
Comment 17•15 years ago
|
||
" a new patch "(In reply to comment #16)
> net patch or could you fix this locally before submitting?
Updated•15 years ago
|
Attachment #440254 -
Flags: review?(stejohns) → review+
Assignee | ||
Updated•15 years ago
|
Assignee: skekki → lhansen
Whiteboard: has-patch
Assignee | ||
Comment 18•15 years ago
|
||
Same patch, but (a) tabs vs spaces fixed, (b) ad-hoc define refactored as AVMTWEAK_EPOC_EMULATOR, (c) the enabling define moved from symbian-platform.h to system-selection.h, where it makes the most sense IMO.
Attachment #440254 -
Attachment is obsolete: true
Attachment #450072 -
Flags: review?(stejohns)
Assignee | ||
Comment 19•15 years ago
|
||
Samuli, any input from you is appreciated as well.
Assignee | ||
Comment 20•15 years ago
|
||
Pushed in anticipation of review:
tamarin-redux changeset: 4785:e109b4ac2b77
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•15 years ago
|
Attachment #450072 -
Flags: review?(stejohns) → review+
You need to log in
before you can comment on or make changes to this bug.
Description
•