Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEGV found by address sanitizer #104

Closed
chipitsine opened this issue May 22, 2019 · 2 comments
Closed

SEGV found by address sanitizer #104

chipitsine opened this issue May 22, 2019 · 2 comments
Labels
severity: medium This issue is of MEDIUM severity. status: fixed This issue is a now-fixed bug. subsystem: core The issue is within the core of haproxy. type: bug This issue describes a bug.

Comments

@chipitsine
Copy link
Member

full log: https://travis-ci.org/chipitsine/haproxy-1/jobs/535709949#L1938-L1948

***  h1    0.1 debug|    #0 0x921d3f in updt_fd_polling /home/travis/build/chipitsine/haproxy-1/include/proto/fd.h:128:20
***  h1    0.1 debug|    #1 0x921d3f in fd_want_recv /home/travis/build/chipitsine/haproxy-1/include/proto/fd.h:486
***  h1    0.1 debug|    #2 0x921d3f in mworker_pipe_register_per_thread /home/travis/build/chipitsine/haproxy-1/src/mworker.c:377
***  h1    0.1 debug|    #3 0x7118ab in run_thread_poll_loop /home/travis/build/chipitsine/haproxy-1/src/haproxy.c:2527:8
***  h1    0.1 debug|    #4 0x70f01d in main /home/travis/build/chipitsine/haproxy-1/src/haproxy.c:3215:3
***  h1    0.1 debug|    #5 0x7f4fb244e82f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
***  h1    0.1 debug|    #6 0x434118 in _start (/home/travis/build/chipitsine/haproxy-1/haproxy+0x434118)
***  h1    0.1 debug|
***  h1    0.1 debug|AddressSanitizer can not provide additional info.
***  h1    0.1 debug|SUMMARY: AddressSanitizer: SEGV /home/travis/build/chipitsine/haproxy-1/include/proto/fd.h:128:20 in updt_fd_polling
***  h1    0.1 debug|==6039==ABORTING
***  h1    0.1 debug|[ALERT] 141/100950 (6032) : Current worker #1 (6039) exited with code 1 (Exit)
***  h1    0.1 debug|[ALERT] 141/100950 (6032) : exit-on-failure: killing every processes with SIGTERM
***  h1    0.1 debug|[WARNING] 141/100950 (6032) : Former worker #1 (6035) exited with code 143 (Terminated)
***  h1    0.1 debug|[WARNING] 141/100950 (6032) : All workers exited. Exiting... (1)
@chipitsine chipitsine added status: needs-triage This issue needs to be triaged. type: bug This issue describes a bug. labels May 22, 2019
@wtarreau
Copy link
Member

wtarreau commented May 22, 2019 via email

haproxy-mirror pushed a commit that referenced this issue May 22, 2019
…backs

We currently have the ability to register functions to be called early
on thread creation and at thread deinitialization. It turns out this is
not sufficient because certain such functions may use resources that are
being allocated by the other ones, thus creating a race condition depending
only on the linking order. For example the mworker needs to register a
file descriptor while the pollers will reallocate the fd_updt[] array.
Similarly logs and trashes may be used by some init functions while it's
unclear whether they have been deduplicated.

The same issue happens on deinit, if the fd_updt[] or trash is released
before some functions finish to use them, we'll get into trouble.

This patch creates a couple of early and late callbacks for per-thread
allocation/freeing of resources. A few init functions were moved there,
and the fd init code was split between the two (since it used to both
allocate and initialize at once). This way the init/deinit sequence is
expected to be safe now.

This patch should be backported to 1.9 as at least the trash/log issue
seems to be present. The run_thread_poll_loop() code is a bit different
there as the mworker is not a callback, but it will have no effect and
it's enough to drop the mworker changes.

This bug was reported by Ilya Shipitsin in github issue #104.
@chipitsine
Copy link
Member Author

fixed

@TimWolla TimWolla added severity: medium This issue is of MEDIUM severity. status: fixed This issue is a now-fixed bug. subsystem: core The issue is within the core of haproxy. and removed status: needs-triage This issue needs to be triaged. labels May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: medium This issue is of MEDIUM severity. status: fixed This issue is a now-fixed bug. subsystem: core The issue is within the core of haproxy. type: bug This issue describes a bug.
Projects
None yet
Development

No branches or pull requests

3 participants