public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Dave Nadler <drn@nadler.com>
To: Freddie Chopin <freddie_chopin@op.pl>, newlib@sourceware.org
Subject: Re: Confusion about possibly unsafe malloc_r?
Date: Sun, 25 Jun 2017 14:28:00 -0000	[thread overview]
Message-ID: <e07056d6-34dd-55a9-e39c-6a0c8ad9aa98@nadler.com> (raw)
In-Reply-To: <1498371337.1704.1.camel@op.pl>

Thanks Freddie. If I understand your answer correctly, printf's call chain's
use of _GLOBAL_REENT should be OK because this particular memory is
protected by a global lock.

I studied the newlib documentation and looked in syscalls, but did not find
anything explaining how to implement "retargetable locks" as you mention.
I did understand that I must implement env_locks to use set_env/get_env,
and that I did not need to implement the corresponding malloc locks.
I read a half-dozen articles about embedding/porintg newlib and failed
to find this...

Could you point me at documentation (or sources) explaining how
to implement "retargetable locks"?

Thanks for the help!
Best Regards, Dave

On 6/25/2017 2:15 AM, Freddie Chopin wrote:
> On Sat, 2017-06-24 at 18:42 -0400, Dave Nadler wrote:
>> Is this OK? I'm paranoid about thread safety!
> Then it's worth mentioning that newlib and FreeRTOS will _NEVER_ be
> fully thread safe unless you are using a toolchain with retargetable
> locks and your project has support code for these locks.
>
> printf()-style families partially use global reent structure, this is
> expected. Trace the calls of the mentioned functions in newlib source
> and you'll see that sometimes _GLOBAL_REENT is used, sometimes thread's
> reent.
>
> Regards,
> FCh

-- 
Dave Nadler, USA East Coast voice (978) 263-0097,drn@nadler.com, Skype
  Dave.Nadler1

  reply	other threads:[~2017-06-25 14:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-24 22:42 Dave Nadler
2017-06-25  6:18 ` Freddie Chopin
2017-06-25 14:28   ` Dave Nadler [this message]
     [not found]   ` <a720c7bc-1795-ee25-d757-359e7d9942ec@nadler.com>
2017-06-27 18:26     ` Freddie Chopin
2017-06-27 20:07       ` Dave Nadler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e07056d6-34dd-55a9-e39c-6a0c8ad9aa98@nadler.com \
    --to=drn@nadler.com \
    --cc=freddie_chopin@op.pl \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).