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

pkg: TLSF does not build for 16 bit platforms #4612

Closed
OlegHahm opened this issue Jan 7, 2016 · 18 comments
Closed

pkg: TLSF does not build for 16 bit platforms #4612

OlegHahm opened this issue Jan 7, 2016 · 18 comments
Assignees
Labels
Area: pkg Area: External package ports Platform: MSP Platform: This PR/issue effects MSP-based platforms State: won't fix State: The issue can not or will not be fixed Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@OlegHahm
Copy link
Member

OlegHahm commented Jan 7, 2016

/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:73:1: error: size of array 'static_assert73' is negative
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:74:1: error: size of array 'static_assert74' is negative
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:78:1: error: size of array 'static_assert78' is negative
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:136:1: error: left shift count >= width of type [-Werror]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:136:38: error: initializer element is not a constant expression [-Werror]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c: In function 'offset_to_block'
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:222:9: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:222:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c: In function 'align_ptr'
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:278:4: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:280:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c: In function 'tlsf_add_pool'
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:602:7: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c: In function 'tlsf_create'
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:643:7: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c: In function 'tlsf_memalign'
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:695:16: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:695:16: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:703:31: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:703:31: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:707:10: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
/home/oleg/git/miniature-dangerzone/ccnlriot/bin/z1/tlsf-src/tlsf.c:707:10: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
cc1: all warnings being treated as errors
@OlegHahm OlegHahm added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Platform: MSP Platform: This PR/issue effects MSP-based platforms Area: pkg Area: External package ports labels Jan 7, 2016
@OlegHahm OlegHahm added this to the Release 2016.03 milestone Jan 7, 2016
@miri64
Copy link
Member

miri64 commented Jan 7, 2016

I have a dim memory that this was a constraint of TLSF to achieve O(1) runtime.

@haukepetersen
Copy link
Contributor

wont be fixed for this release -> postponed.

@haukepetersen haukepetersen modified the milestones: Release 2016.07, Release 2016.04 Apr 20, 2016
@kYc0o
Copy link
Contributor

kYc0o commented Jul 11, 2016

Is this issue still present?

@OlegHahm
Copy link
Member Author

AFAIR this is an inherent problem of the TLSF implementation. One way to go around it, would be just not to offer TLSF support for 16-bit platforms and add another package for malloc on these platforms.

@kYc0o
Copy link
Contributor

kYc0o commented Jul 26, 2016

Ok well let's discuss it for the next release.

@kYc0o kYc0o modified the milestones: Release 2016.10, Release 2016.07 Jul 26, 2016
@miri64
Copy link
Member

miri64 commented Nov 4, 2016

I say the same, since it is an inherent problem I don't see it necessary to mark it as a "known issue"

@miri64 miri64 modified the milestones: Release 2017.01, Release 2016.10 Nov 4, 2016
@PeterKietzmann PeterKietzmann modified the milestones: Release 2017.01, Release 2017.04 Jan 26, 2017
@Umleitungen
Copy link

hello,
is this fixed? I got the same issue at the release 2016.10, when I try to build ccn-lite-replay example to z1 board.

@OlegHahm
Copy link
Member Author

No, it's not fixed - and probably won't be fixed. For 16 bit platforms you have to use an alternative malloc() implementation.

@kYc0o
Copy link
Contributor

kYc0o commented Jul 17, 2018

No, it's not fixed - and probably won't be fixed

#9006 didn't help on this is it? I guess it wasn't tested for 16bit platforms but I'd like to know if there's a connection.

@kYc0o kYc0o assigned jcarrano and unassigned Kijewski Jul 17, 2018
@miri64
Copy link
Member

miri64 commented Jul 17, 2018

Since the pkg's doc clearly states, that it only work for 32-bit platforms, this issue is a classic example for a wontfix ;-). However, I agree with @OlegHahm on

For 16 bit platforms you have to use an alternative malloc() implementation.

@jcarrano didn't you find something like this?

@jcarrano
Copy link
Contributor

jcarrano commented Jul 18, 2018

@OlegHahm @miri64 Take a look at UMM malloc. It seems quite nice, it's workings are documented and it has very low overhead. Also, unlike TLSF, it has no tunable parameters.

It uses double linked lists, with 16bit offsets instead of pointers, because you will never be managing so much memory in a MCU. I thinks it's simplicity and low overhead could mean that we could use it to replace all usages of custom allocators (so we will still have #9434 -style bugs, but only once)

Downsides: It is not O(1), but I don't think there's such a huge need for O(1), arbitrarily-sized block allocators (correct me if I'm wrong). Also, it would need some modifications in order to work with user-supplied arrays (looking at the code, it seems totally doable).

On my part, I could use it for my Lua work but to make sure time is well spent I won't do anything unless there's interest from more people.

@jcarrano jcarrano added the State: won't fix State: The issue can not or will not be fixed label Jul 18, 2018
@kaspar030
Copy link
Contributor

Downsides: It is not O(1), but I don't think there's such a huge need for O(1), arbitrarily-sized block allocators (correct me if I'm wrong).

O(1) means it is suitable for realtime code.
tlsf has some other desirable properties, e.g., a paper describing it's fragmentation behaviour.

If those are not needed, what's wrong with newlib's malloc()?

@jcarrano
Copy link
Contributor

O(1) means it is suitable for realtime code.

If the rest of the code is not O(1), then it does not matter. If the allocator is O(n) and n is known beforehand and the worst case fits into the time available, it does not matter either.

If those are not needed, what's wrong with newlib's malloc()?

I'm using TLSF because you can provide an array and do allocations there. malloc() uses a system-wide pool.

  • A leak will last until the device is reset.
  • One subsystem can exhaust memory, leading to failure in another subsystem.
  • As already mentioned in newlib: add thread safe implementation #8619, there may be some issues with multiple threads calling malloc().

For my particular use case (Lua), I wanted to isolate the interpreter from the rest of the system as much as possible.

@OlegHahm
Copy link
Member Author

How about closing this issue and open another one as a feature request for a O(1) memory allocator that supports platforms < 32 bit?

@miri64
Copy link
Member

miri64 commented Sep 17, 2018

👍

@jcarrano
Copy link
Contributor

@OlegHahm I agree. Also, in my opinion, a O(n) allocator that works on user-supplied chunks of memory can be useful too.

@OlegHahm
Copy link
Member Author

Totally agreed. I think in the best case we provide multiple pool-based memory allocators.

@jcarrano
Copy link
Contributor

How about closing this issue and open another one as a feature request for a O(1) memory allocator that supports platforms < 32 bit?

Agreed. Closing this - if anyone ever finds the need for a O(1) allocator supporting <32 bits, feel free to open an issue (or better a PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: pkg Area: External package ports Platform: MSP Platform: This PR/issue effects MSP-based platforms State: won't fix State: The issue can not or will not be fixed Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

10 participants