raiden00pl opened a new pull request, #20626:
URL: https://github.com/apache/nuttx/pull/20626

   
   ## Summary
   
   The linker symbols _stdata/_etdata/_stbss/_etbss are uint8_t arrays
   since commit 70290b6 ("arch: Change the linker generated symbols from
   uint32_t to uint8_t *"), but riscv_tls.c still multiplied their
   differences by sizeof(uint32_t).  up_tls_size() reserved four times the
   TLS block size and up_tls_initialize() copied four times the size of
   .tdata, so the bytes that follow .tdata in the image (.data) overwrote
   the .tbss variables of every new thread.
   
   ARM had the same problem and was fixed by commit fac7674 ("arch/arm:
   Fix TLS initialization to account for padding between sections").
   Apply the same change here: use byte differences, and zero .tbss after
   the alignment padding between .tdata and .tbss.
   
   ## Impact
   
   bugfix
   
   ## Testing
   
   Found with CPython on rv-virt (CONFIG_SCHED_THREAD_LOCAL=y, toolchain
   built with --enable-tls): _Py_tss_tstate in .tbss was not NULL in new
   threads, "Fatal Python error: _PyThreadState_Attach: non-NULL old thread
   state".  Not seen in CI: the xPack riscv-none-elf toolchain is built with
   --disable-tls, so __thread uses emulated TLS and .tdata/.tbss are empty.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to