Skip to content

Avoid nullptr access#89

Closed
ivannp wants to merge 2 commits intodds-bridge:developfrom
ivannp:develop
Closed

Avoid nullptr access#89
ivannp wants to merge 2 commits intodds-bridge:developfrom
ivannp:develop

Conversation

@ivannp
Copy link

@ivannp ivannp commented Dec 4, 2018

Merely loading libdds.so on Ubuntu crashes the parent program on exit. To repro, run the following python command:

python -c 'from ctypes import *; dll = CDLL("libdds.so");'

I chased it down to trying to release memory on exit. It looks like the logic behind freeing the memory is broken, when the thread count is less than what's in the array. One might argue that this fix fixes the symptom, but it's better to avoid accessing pointers blindly.

This fix fixes the problem only on 18.04. On 16.04 it seems we are hitting the following line from Memory.cpp:

cout << "Memory::GetPtr: " << thrId << " vs. " << nThreads << endl;

From a quick inspection of the code, I expect to be similar issue. Haven't spent the time debugging it yet.

@t3nsor
Copy link

t3nsor commented Dec 20, 2018

I think the code that determines the amount of free memory (Memory.cpp:228) may be the issue. On my system (Debian 9) it produces 0. Note that the full output of free -k for me is:

          total        used        free      shared  buff/cache   available

Mem: 16198028 5259516 808524 173588 10129988 10428852
Swap: 0 0 0

The output format was changed about 4 years ago: https://gitlab.com/procps-ng/procps/commit/f47001c9e91a1e9b12db4497051a212cf49a87b1

@df7cb
Copy link
Contributor

df7cb commented Dec 21, 2018

See #88.

@sorenhein
Copy link
Contributor

Thanks. It did fix your issue, but it seems that rimmington fixed some larger issues that included yours, so I've gone with his pull request.

@sorenhein sorenhein closed this Jul 25, 2020
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.

4 participants