Overview
| Artifact ID: | e1b313d9f54f625d3eb17e2e6bbd8a854d64bf772a85daabaf977f79a5bffa15 |
|---|---|
| Ticket: | 8dd2807066d7cc4d8604164f39b7f0d65c0dc321
bug in single-argument 'max' with bignums |
| User & Date: | sebres on 2025-11-13 11:48:46 |
Changes
- closedate changed to: "2460992.9922062"
- closer changed to: "sebres"
- icomment:
<blockquote>> I can imagine a possibility that if an existing allocation from a previous call is too big for a smaller bignum, it is reallocated</blockquote> Yes, but it'd be the pointer stored in mp_int::dp, so quasi pointer in pointer (of ptr1/ptr2), whereas ptr1/ptr2 themselves always point to the same address in TSD (per thread). <blockquote>> In which case ptr1 may be != ptr2 but no longer even points to valid storage.</blockquote> No, it cannot. TSD is allocated once per thread and remains unchanged for every static anchor. If GetNumberFromObj returned different pointers one of them is not a bignum, if they are equal - both are bignum and the last win. This variant (well, a bit more complex) works on my side already dozen years without any issue. However I think it'd be better to backport more from there, e. g. yet another GetNumberFromObj to avoid getting bignum in TSD (just a performance thing) and then one could always use TclUnpackBignum for local variable for any constant accesses to bignum type. This way one could eliminate almost every Tcl_GetBignumFromObj/Tcl_TakeBignumFromObj invocation and improve the performance drastically.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"