Skip to content

Switch to Dart v2.6 #54

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

Closed
vaind opened this issue Oct 24, 2019 · 17 comments
Closed

Switch to Dart v2.6 #54

vaind opened this issue Oct 24, 2019 · 17 comments

Comments

@vaind
Copy link
Contributor

vaind commented Oct 24, 2019

Dart v2.6 is going to break compatibility in FFI (it was in "preview" after all, so no surprise there). From what I've seen with the current dev version (.8), it was rather significant so I have a feeling we'll have to drop Dart v2.5 compatibility to be able to switch to v2.6

See the changes that have already landed in the dev release and the FFI project board for what's coming.

@liquidiert
Copy link
Contributor

Memory management has been removed 😍

@greenrobot
Copy link
Member

There's no definite timeline yet on the 2.6 release, I suppose?

How about

  1. When we get really close to a 2.6 release, e.g. RC2 or final release. We do a 2.5 release, make the adjustments for 2.6 and release this asap. Afterwards we focus on 2.6 only.
  2. Like 1.), but prep a 2.6 branch in parallel

This way, we have another 2.5 release.

@vaind
Copy link
Contributor Author

vaind commented Oct 24, 2019

There's no definite timeline yet on the 2.6 release, I suppose?

Assuming it's D26 milestone, it's 9 days past due. They don't do RC or anything like that, just go from 2.5.0-dev.4.0 to 2.5.0. But from what I see, I'd say we're pretty close to a final release right now. Considering the last 3 releases (2.3.0, 2.4.0, 2.5.0) all happened on Friday, that may be tomorrow or the next week at most I'd say.

So if we want to do a release before, we should probably do it ASAP. I'd say today.

@vaind
Copy link
Contributor Author

vaind commented Oct 24, 2019

Some volunteers who'd like to pitch in with the 2.6 support? @liquidiert or @Buggaboo maybe? 😄

@Buggaboo
Copy link
Contributor

Sure, I'd like to get property query out of the way first.

@liquidiert
Copy link
Contributor

Would be happy to help 😁

@Buggaboo
Copy link
Contributor

Sure, I'd like to get property query out of the way first.

I changed my mind, I'm stuck. @vaind Can you open a new dev-2.6 branch? Dakujeme.

We should start with the imports.

I expect free and allocate to break. Probably Struct, anything related to ffi really.
Let's see if attachFinalizer or something like that is available, so we can deallocate, or by whatever free has been replaced with.

I'm reluctant to use brew's dart-2.6-devX builds; I prefer to wait for the non-dev, stable(?) 2.6 version. I can't be arsed to compile my own either.

@vaind
Copy link
Contributor Author

vaind commented Oct 24, 2019

... Dakujeme.

dev-dart26 You're welcome 🤣 But it's just dev because I haven't really had time to look into this yet.

I'm reluctant to use brew's dart-2.6-devX builds; I prefer to wait for the non-dev, stable(?) 2.6 version. I can't be arsed to compile my own either.

I just download and extract the SDK & set its path in the IDE. Maybe that works for you as well: https://dart.dev/tools/sdk/archive#dev-channel

@Buggaboo
Copy link
Contributor

Buggaboo commented Oct 25, 2019

Done. Except the Utf8 thing. I'm taking a break.

@liquidiert
Copy link
Contributor

@Buggaboo what's it with utf8? For me all tests work with your latest changes 👍

@Buggaboo
Copy link
Contributor

Buggaboo commented Oct 25, 2019

@Buggaboo what's it with utf8? For me all tests work with your latest changes 👍

It works, I give no guarantees that it does not leak. I don't understand/see how the Struct knows about the Pointer<Uint>, for all I know free cleans up the Struct and not the alloc'ed Pointer<Uint> of size n + 1. In my C/C++ days, I could run valgrind.

@Buggaboo
Copy link
Contributor

I thought about this, for a bit. The cast only changes the underlying type (generic arg) of the Pointer, it should not change the allocation size.

@greenrobot greenrobot changed the title Dart v2.6 support; v2.5 compatibility Switch to Dart v2.6 Nov 6, 2019
@greenrobot
Copy link
Member

Does #57 work with the final Dart 2.6? Anything outstanding?

Btw, ouch...

@Buggaboo
Copy link
Contributor

Buggaboo commented Nov 6, 2019

I used brew's final 2.6. Still works. Some refactoring might be necessary, and dartfm after merging.

@vaind
Copy link
Contributor Author

vaind commented Nov 14, 2019

It works, I give no guarantees that it does not leak. I don't understand/see how the Struct knows about the Pointer<Uint>, for all I know free cleans up the Struct and not the alloc'ed Pointer<Uint> of size n + 1. In my C/C++ days, I could run valgrind.

FYI, running valgrind wasn't very helpful, at least not the way I tried...

dart2native test/box_test.dart -o box-test
valgrind ./box-test
==25284== HEAP SUMMARY:
==25284==     in use at exit: 91,012 bytes in 188 blocks
==25284==   total heap usage: 12,658 allocs, 12,470 frees, 158,942,897 bytes allocated
==25284== 
==25284== LEAK SUMMARY:
==25284==    definitely lost: 0 bytes in 0 blocks
==25284==    indirectly lost: 0 bytes in 0 blocks
==25284==      possibly lost: 0 bytes in 0 blocks
==25284==    still reachable: 91,012 bytes in 188 blocks
==25284==         suppressed: 0 bytes in 0 blocks
==25284== Rerun with --leak-check=full to see details of leaked memory
==25284== 
==25284== For lists of detected and suppressed errors, rerun with: -s
==25284== ERROR SUMMARY: 10913 errors from 240 contexts (suppressed: 0 from 0)

and each report looks somewhat like:

==25284== Mismatched free() / delete / delete []
==25284==    at 0x48399AB: free (vg_replace_malloc.c:540)
==25284==    by 0x29CB13: ??? (in objectbox-dart/box-test)
==25284==    by 0x29D2D5: ??? (in objectbox-dart/box-test)
==25284==    by 0x48AE152: (below main) (in /usr/lib/libc-2.30.so)
==25284==  Address 0x4bc2630 is 0 bytes inside a block of size 48 alloc'd
==25284==    at 0x483950F: operator new[](unsigned long) (vg_replace_malloc.c:433)
==25284==    by 0x299A18: ??? (in objectbox-dart/box-test)
==25284==    by 0x29C745: ??? (in objectbox-dart/box-test)
==25284==    by 0x29D2D5: ??? (in objectbox-dart/box-test)
==25284==    by 0x48AE152: (below main) (in /usr/lib/libc-2.30.so)

@Buggaboo
Copy link
Contributor

Buggaboo commented Nov 14, 2019

Cool! I didn't know that we could target dart2native with this codebase! I have to read up on the dart2native memory management; it might be allocating a memory pool and releasing on exit.

Or there is no leak... with the free after the cast. Counter-test by removing the free, then check again with valgrind?

@vaind
Copy link
Contributor Author

vaind commented Nov 18, 2019

Support of Dart2.6 is implemented and released. Thanks @Buggaboo

followup for valgrind: #72

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

No branches or pull requests

4 participants