Skip to content

[Backport][0.9 to 0.8] | [Backport][main to 0.9] | Fix crash in threads_create_join on partial failure (#1252) (#1328) - #1393

Merged
lihuiba merged 1 commit into
release/0.8from
backport-pr-465203011306b2acabc014bb9fbab5252f06f071-0.8
Jun 16, 2026
Merged

[Backport][0.9 to 0.8] | [Backport][main to 0.9] | Fix crash in threads_create_join on partial failure (#1252) (#1328) #1393
lihuiba merged 1 commit into
release/0.8from
backport-pr-465203011306b2acabc014bb9fbab5252f06f071-0.8

Conversation

@photonlibos

Copy link
Copy Markdown
Collaborator

[Backport][main to 0.9] | Fix crash in threads_create_join on partial failure (#1252) (#1328)

When thread_create() fails mid-loop, only join threads that were
actually created. Previously the join loop iterated all n slots,
calling thread_join on uninitialized pointers (stack array case)
or nullptr (vector case), causing a segfault.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

  • Address review: return # of threads created, use created++ index

Per maintainer feedback:

  • threads_create_join now returns the actual number of threads created
    (< n on partial failure), so callers can detect partial failure.
  • Use pthreads[created++] = th instead of a separate created++ line.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com


Co-authored-by: Claude Opus 4.6 noreply@anthropic.com

  • Update thread.h

  • Update thread.h


Co-authored-by: Jiangtian Feng fengjiangtian.fjt@alibaba-inc.com
Co-authored-by: Claude Opus 4.6 noreply@anthropic.com
Co-authored-by: Coldwings coldwings@me.com
Co-authored-by: Huiba Li huiba.lhb@alibaba-inc.com
Generated by Backport Auto PR, by cherry-pick related commits.

Please review and decide whether to merge or close this backport PR.

… failure (#1252)  (#1328)

* Fix crash in threads_create_join on partial failure (#1252)

* Fix crash in threads_create_join on partial failure

When thread_create() fails mid-loop, only join threads that were
actually created. Previously the join loop iterated all n slots,
calling thread_join on uninitialized pointers (stack array case)
or nullptr (vector case), causing a segfault.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Address review: return # of threads created, use created++ index

Per maintainer feedback:
- threads_create_join now returns the actual number of threads created
  (< n on partial failure), so callers can detect partial failure.
- Use pthreads[created++] = th instead of a separate created++ line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* Update thread.h

* Update thread.h

---------

Co-authored-by: Jiangtian Feng <fengjiangtian.fjt@alibaba-inc.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Coldwings <coldwings@me.com>
Co-authored-by: Huiba Li <huiba.lhb@alibaba-inc.com>
@lihuiba
lihuiba merged commit 8859357 into release/0.8 Jun 16, 2026
14 checks passed
@photonlibos
photonlibos deleted the backport-pr-465203011306b2acabc014bb9fbab5252f06f071-0.8 branch June 16, 2026 06:52
lihuiba added a commit that referenced this pull request Jun 17, 2026
… failure (#1252)  (#1328) (#1393) (#1428)

* Fix crash in threads_create_join on partial failure (#1252)

* Fix crash in threads_create_join on partial failure

When thread_create() fails mid-loop, only join threads that were
actually created. Previously the join loop iterated all n slots,
calling thread_join on uninitialized pointers (stack array case)
or nullptr (vector case), causing a segfault.



* Address review: return # of threads created, use created++ index

Per maintainer feedback:
- threads_create_join now returns the actual number of threads created
  (< n on partial failure), so callers can detect partial failure.
- Use pthreads[created++] = th instead of a separate created++ line.



---------



* Update thread.h

* Update thread.h

---------

Co-authored-by: Jiangtian Feng <fengjiangtian.fjt@alibaba-inc.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Coldwings <coldwings@me.com>
Co-authored-by: Huiba Li <huiba.lhb@alibaba-inc.com>
lihuiba added a commit that referenced this pull request Jun 17, 2026
… failure (#1252)  (#1328) (#1393) (#1428) (#1459)

* Fix crash in threads_create_join on partial failure (#1252)

* Fix crash in threads_create_join on partial failure

When thread_create() fails mid-loop, only join threads that were
actually created. Previously the join loop iterated all n slots,
calling thread_join on uninitialized pointers (stack array case)
or nullptr (vector case), causing a segfault.



* Address review: return # of threads created, use created++ index

Per maintainer feedback:
- threads_create_join now returns the actual number of threads created
  (< n on partial failure), so callers can detect partial failure.
- Use pthreads[created++] = th instead of a separate created++ line.



---------



* Update thread.h

* Update thread.h

---------

Co-authored-by: Jiangtian Feng <fengjiangtian.fjt@alibaba-inc.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Coldwings <coldwings@me.com>
Co-authored-by: Huiba Li <huiba.lhb@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants