Skip to content

md_config_t: change from class to struct as the name indicates - #205

Merged
gregsfortytwo merged 1 commit into
ceph:masterfrom
dalgaaf:wip-da-md_config-class
Apr 12, 2013
Merged

gregsfortytwo merged 1 commit into
ceph:masterfrom
dalgaaf:wip-da-md_config-class

Conversation

@dalgaaf

@dalgaaf dalgaaf commented Apr 8, 2013

Copy link
Copy Markdown
Contributor

Change md_config_t from class to struct to fix some issues
from clang. The name indicates it's a struct so change it to
struct and unify the used type in some places.

Signed-off-by: Danny Al-Gaaf [email protected]

Change md_config_t from class to struct to fix some issues
from clang. The name indicates it's a struct so change it to
struct and unify the usaged type.

Signed-off-by: Danny Al-Gaaf <[email protected]>
@gregsfortytwo

Copy link
Copy Markdown
Member

What kinds of issues does clang have with it as things stand? I'm not necessarily opposed but md_config_t has been slowly growing more class-like attributes so this might be going the wrong direction (it used to really just be a collection of attributes, but now it's got the observer framework etc, and indications so far have been we need more options to be accessed through mediators instead of directly).

@dalgaaf

dalgaaf commented Apr 9, 2013

Copy link
Copy Markdown
Contributor Author

The first issue for me is the naming. The *_t is used for structs and not classes.

The other issue clang complains about is that md_config_t is defined as class but declared and used as struct in other places of the code. This is confusing if you read the code. I would prefer to use only one type and not to mix class and structs all the time (for the same data structure, md_config_t in this case).

Btw. I'm not complete sure yet, but the call offsetof(struct md_config_t, name) in src/common/config.cc may cause problems with c++ versions < C++11:

offsetof (type,member)
C: type shall be a structure or union type.
C++98: type shall be a POD class (including unions).
C++11: type shall be a standard-layout class (including unions).

And for C++98 this isn't fulfilled since md_config_t is "standard-layout" (okay with C++11) but no-POD.

@gregsfortytwo

Copy link
Copy Markdown
Member

Sorry; this reply got buried in my email somehow. Merging now, and do keep us updated about that offsetof call.

gregsfortytwo added a commit that referenced this pull request Apr 12, 2013
md_config_t: change from class to struct as the name indicates

Reviewed-by: Greg Farnum <[email protected]>
@gregsfortytwo
gregsfortytwo merged commit 98e4c86 into ceph:master Apr 12, 2013
liewegas pushed a commit that referenced this pull request Dec 14, 2016
erasure-code: isa plugin thrashods suite

Reviewed-by: Samuel Just <[email protected]>
liewegas pushed a commit that referenced this pull request Dec 14, 2016
jenkins: fail fast during job execution
theanalyst pushed a commit to theanalyst/ceph that referenced this pull request Oct 4, 2018
[SES5] qa: tier[12]/functional: deploy cluster with --openstack and --tuned=on options
liewegas pushed a commit to liewegas/ceph that referenced this pull request Nov 5, 2021
…-update

Replaces all lorem ipsum text in Discover -> Technology
tserong added a commit to tserong/ceph that referenced this pull request Sep 12, 2023
rgw/s3gw: ensure s3gw_telemetry is non-null before stop
tchaikov added a commit that referenced this pull request May 5, 2026
When building with ASan, it reports leaks in five tests that exercise
CPython 3.10 either as an external process (bin/ceph) or embedded in
unittests:

   #36  smoke.sh                    (timeout, via bin/ceph)
  #205  unittest_mgr_pyformatter    (libpython3.10.so embedded)
  #206  unittest_mgr_pyutil         (libpython3.10.so embedded)
  #210  mgr-dashboard-smoke.sh      (via bin/ceph)
  #225  safe-to-destroy.sh          (via bin/ceph)

A representative stack from #210:

  Direct leak of 25846 byte(s) in 28 object(s) allocated from:
    #0  malloc
    #1  /usr/bin/python3.10+0x16d7be
  Direct leak of 20456 byte(s) in 29 object(s):
    #1  PyDict_Copy /usr/bin/python3.10+0x16ae06
  Direct leak of 8456 byte(s) in 14 object(s):
    #1  _PyObject_GC_NewVar /usr/bin/python3.10+0x14fc57

The unittests show the same shape against /lib/.../libpython3.10.so.

These are CPython 3.10 runtime artefacts, not Ceph bugs.  In CPython
3.10, Py_FinalizeEx() leaves a set of interpreter-internal allocations
(module namespace dict copies, GC-tracked variable-size containers,
type-method caches, interned strings) heap-allocated until process
exit; the OS reclaims them.  PEP 683 (Immortal Objects, accepted for
Python 3.12) extends pylifecycle.c::finalize_modules() to deallocate
these remaining objects during runtime shutdown:

  "During runtime shutdown, the strategy will be to first let the
  runtime try to do its best effort of deallocating these instances
  normally.  Most of the module deallocation will now be handled by
  pylifecycle.c:finalize_modules() where we clean up the remaining
  modules as best as we can."
                            -- PEP 683, https://peps.python.org/pep-0683/

The qa/lsan.supp file has carried the empirical note "python3.12
doesn't leak anything" since the file was introduced (commit
8c099a5, "asan: add qa/lsan.supp for leak sanitizer
suppressions", Mar 2023).  An empirical reproduction with a minimal
Py_Initialize()/Py_FinalizeEx() program built against Python 3.13
under -fsanitize=address reports zero leaks; the same minimal test
against Python 3.10 (CI environment) reports the leaks shown above.

Add three suppressions to qa/lsan.supp's existing 3.9-3.11 block:

 - leak:^PyDict_Copy and leak:^_PyObject_GC_NewVar match the two
   exported CPython functions visible in the leak stacks.
 - leak:python3.10 substring-matches the module path in the stack
   frame, catching unsymbolised offsets in both the /usr/bin/python3.10
   binary and the libpython3.10.so.1.0 shared object.  Mirrors the
   existing leak:libsqlite3.so pattern earlier in the file.

The whole block (including the existing PyMem_Malloc entry above) can
be removed once CI runs on Python >= 3.12.

Signed-off-by: Kefu Chai <[email protected]>
AnuragRaut08 pushed a commit to AnuragRaut08/ceph that referenced this pull request Sep 30, 2026
When building with ASan, it reports leaks in five tests that exercise
CPython 3.10 either as an external process (bin/ceph) or embedded in
unittests:

   ceph#36  smoke.sh                    (timeout, via bin/ceph)
  ceph#205  unittest_mgr_pyformatter    (libpython3.10.so embedded)
  ceph#206  unittest_mgr_pyutil         (libpython3.10.so embedded)
  ceph#210  mgr-dashboard-smoke.sh      (via bin/ceph)
  ceph#225  safe-to-destroy.sh          (via bin/ceph)

A representative stack from ceph#210:

  Direct leak of 25846 byte(s) in 28 object(s) allocated from:
    #0  malloc
    ceph#1  /usr/bin/python3.10+0x16d7be
  Direct leak of 20456 byte(s) in 29 object(s):
    ceph#1  PyDict_Copy /usr/bin/python3.10+0x16ae06
  Direct leak of 8456 byte(s) in 14 object(s):
    ceph#1  _PyObject_GC_NewVar /usr/bin/python3.10+0x14fc57

The unittests show the same shape against /lib/.../libpython3.10.so.

These are CPython 3.10 runtime artefacts, not Ceph bugs.  In CPython
3.10, Py_FinalizeEx() leaves a set of interpreter-internal allocations
(module namespace dict copies, GC-tracked variable-size containers,
type-method caches, interned strings) heap-allocated until process
exit; the OS reclaims them.  PEP 683 (Immortal Objects, accepted for
Python 3.12) extends pylifecycle.c::finalize_modules() to deallocate
these remaining objects during runtime shutdown:

  "During runtime shutdown, the strategy will be to first let the
  runtime try to do its best effort of deallocating these instances
  normally.  Most of the module deallocation will now be handled by
  pylifecycle.c:finalize_modules() where we clean up the remaining
  modules as best as we can."
                            -- PEP 683, https://peps.python.org/pep-0683/

The qa/lsan.supp file has carried the empirical note "python3.12
doesn't leak anything" since the file was introduced (commit
8c099a5, "asan: add qa/lsan.supp for leak sanitizer
suppressions", Mar 2023).  An empirical reproduction with a minimal
Py_Initialize()/Py_FinalizeEx() program built against Python 3.13
under -fsanitize=address reports zero leaks; the same minimal test
against Python 3.10 (CI environment) reports the leaks shown above.

Add three suppressions to qa/lsan.supp's existing 3.9-3.11 block:

 - leak:^PyDict_Copy and leak:^_PyObject_GC_NewVar match the two
   exported CPython functions visible in the leak stacks.
 - leak:python3.10 substring-matches the module path in the stack
   frame, catching unsymbolised offsets in both the /usr/bin/python3.10
   binary and the libpython3.10.so.1.0 shared object.  Mirrors the
   existing leak:libsqlite3.so pattern earlier in the file.

The whole block (including the existing PyMem_Malloc entry above) can
be removed once CI runs on Python >= 3.12.

Signed-off-by: Kefu Chai <[email protected]>
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