Re: Race in ETimeFormat [PATCH]
"Mark S. Miller" <[email protected]> Thu, 28 Jul 2011 06:53:31 -0700
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <CABHxS9gtErFmG_NgGW+i1g=MO2586gh3RBPes=fMukVxE0Dkeg@mail.gmail.com> |
Hi Thomas, I see at < http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html > Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally. which surprises me. But given that, your fix looks good and necessary. Thanks! On Thu, Jul 28, 2011 at 2:15 AM, Thomas Leonard < tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]> wrote: > If two vats use ETimeFormat at once, it may fail. Test case: > > > def seedVat := <elang:interp.seedVatAuthor>(<unsafe>) > seedVat(`def timeFormat := > <import:org.erights.e.develop.format.makeETimeFormat> > def random := <unsafe:java.util.makeRandom>() > while (true) { timeFormat.formatTime(random.nextInt()) }`) > > def timeFormat := <import:org.erights.e.develop.format.makeETimeFormat> > while (true) {timeFormat.formatTime(0) } > > > Sample output: > > $ rune time.e > # problem: <ArrayIndexOutOfBoundsException: 13> > # > # - static ETimeFormat#formatTime(long) > # . <makeETimeFormat>.formatTime(0) > # @ formatTime/1: </opt/src/e/src/time.e#:span::7:25::7:34> > # - __main$_#run/0 > # . <_>() > # - Loop#run(LoopBody) > # . <__loop>(<_>) > # @ run/1 > # - EExpr#evalToPair(Scope) > # . e`escape __break {\n __lo... }\n }\n > })\n}`.evalToPair(<a Scope>) > # @ evalToPair/1: > <jar:file:/home/tal/.cache/ > 0install.net/implementations/sha1new%3d489654cfd0f86baaf3223c77418b2e3427255731/e.jar!/org/erights/e/elang/cmd/cmdMakerMaker.emaker#:span::128:57::128:66 > > > > > Patch: > > > https://gitorious.org/~tal-itinnov/repo-roscidus/it-innovation/commit/057f7265156b930493ae217277a4e93e442a3400 > > > -- > Dr Thomas Leonard > IT Innovation Centre > Gamma House, Enterprise Road, > Southampton SO16 7NS, UK > > > tel: +44 23 8059 8866 > > mailto:tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected] > http://www.it-innovation.soton.ac.uk/ > _______________________________________________ > e-lang mailing list > [email protected] > http://www.eros-os.org/mailman/listinfo/e-lang > -- Cheers, --MarkM _______________________________________________ e-lang mailing list [email protected] http://www.eros-os.org/mailman/listinfo/e-lang