Re: weird exception on windows

2018-01-05 Thread Szabo Bogdan via Digitalmars-d-learn

On Monday, 18 December 2017 at 22:49:30 UTC, unleashy wrote:
On Friday, 15 December 2017 at 21:56:48 UTC, Steven 
Schveighoffer wrote:

On 12/15/17 10:08 AM, Kagamin wrote:

Maybe this https://issues.dlang.org/show_bug.cgi?id=18084


Thanks for looking into this. I created a PR to fix.

Szabo, can you please try with this patch and see if it fixes 
your issue?


https://github.com/dlang/phobos/pull/5932

-Steve


I created the original issue in Szabo's post. I applied your 
fix, but nothing changed—the test program still crashes with 
the same exception :/


What gives?


It looks like this fix does not work:
https://github.com/dlang/phobos/pull/5932

Does anyone know how to debug this crash?





Re: weird exception on windows

2017-12-18 Thread Szabo Bogdan via Digitalmars-d-learn
On Saturday, 16 December 2017 at 12:01:49 UTC, Steven 
Schveighoffer wrote:

On 12/16/17 5:12 AM, bauss wrote:
On Saturday, 16 December 2017 at 08:07:30 UTC, Szabo Bogdan 
wrote:
On Friday, 15 December 2017 at 21:56:48 UTC, Steven 
Schveighoffer wrote:

On 12/15/17 10:08 AM, Kagamin wrote:

Maybe this https://issues.dlang.org/show_bug.cgi?id=18084


Thanks for looking into this. I created a PR to fix.

Szabo, can you please try with this patch and see if it 
fixes your issue?


https://github.com/dlang/phobos/pull/5932

-Steve


I have installed DMD 2.77.1 and I can not find the patched 
file in the phobos folder... should I try this by building 
the compiler?


It seams that I can not build phobos without compiling dmd.. 
or maybe I don't know how...


Just go and do the changes manually in your local phobos 
folder, wherever you have DMD installed, since you can't build 
phobos or dmd.


Yes, this won't get into the release for a while. So please do 
this manually (just copy the file changed by the pull over the 
existing one).


It's something that doesn't need to be compiled into the phobos 
library, as it's a misrepresentation of the actual object when 
you compile with unittests, so there is no reason to recompile 
phobos.


-Steve


I'm actually a linux and a mac user... this issue happens on a 
windows ci machine at work. I tried to update the file and 
compile phobos with that change, and I don't know how to make it 
work...


`
C:\D\dmd2\src\phobos>make -f win64.mak
cd etc\c\zlib
make -f win64.mak MODEL=64 zlib64.lib "CC=\"\Program Files 
(x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl""\"" 
"LIB=\"\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\bin\amd64\lib""\"" "VCDIR=\Program Files (x86)\Microsoft 
Visual Studio 10.0\VC"
"\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\bin\amd64\cl" /c /O2 /nologo /I"\Program Files 
(x86)\Microsoft Visual Studio 10.0\VC\INCLUDE" /Zl adler32.c
Error: '\Program Files (x86)\Microsoft Visual Studio 
10.0\VC\bin\amd64\cl' not found

`

I don't know where I can find a 64bit toolchain for vs2010... I 
was expecting that dmd uses a newer compiler on windows...


I guess that the best approach for me is to wait the next beta 
release of dmd and try it then...


Thanks for the support!



Re: weird exception on windows

2017-12-16 Thread Szabo Bogdan via Digitalmars-d-learn

On Friday, 15 December 2017 at 13:56:41 UTC, Kagamin wrote:

You said tests fail?

class SourceResult
{
private const
{
string file;
size_t line;
}
	this(string fileName = __FILE__, size_t line = __LINE__, 
size_t range = 6) nothrow

{
this.file = fileName;
this.line = line;
if (!fileName.exists)
{
return;
}
}
}

unittest
{
auto result = new SourceResult("test/values.d", 26);
auto msg = result.file;
}

Does this fail too?


I can not reproduce the crash with this example...



Re: weird exception on windows

2017-12-16 Thread Szabo Bogdan via Digitalmars-d-learn
On Friday, 15 December 2017 at 21:56:48 UTC, Steven Schveighoffer 
wrote:

On 12/15/17 10:08 AM, Kagamin wrote:

Maybe this https://issues.dlang.org/show_bug.cgi?id=18084


Thanks for looking into this. I created a PR to fix.

Szabo, can you please try with this patch and see if it fixes 
your issue?


https://github.com/dlang/phobos/pull/5932

-Steve


I have installed DMD 2.77.1 and I can not find the patched file 
in the phobos folder... should I try this by building the 
compiler?


It seams that I can not build phobos without compiling dmd.. or 
maybe I don't know how...


Re: weird exception on windows

2017-12-15 Thread Szabo Bogdan via Digitalmars-d-learn

On Friday, 15 December 2017 at 09:24:07 UTC, Kagamin wrote:

Try printf debugging in case argument is invalid.


ah .. ok ...

I tried to debug the issue and it looks like the filename is 
valid and there is no null value.


I am thinking that the value is destroyed before it reach the 
`GetFileAttributesW` or during that call... but I don't see how 
that is possible.





Re: weird exception on windows

2017-12-14 Thread Szabo Bogdan via Digitalmars-d-learn

On Thursday, 14 December 2017 at 14:47:25 UTC, Kagamin wrote:

writeln(fileName);
if (!fileName.exists)
{
  return;
}

:)


I'm not sure I understand this solution...


weird exception on windows

2017-12-14 Thread Szabo Bogdan via Digitalmars-d-learn

Hi,

I noticed that sometimes on windows this line of code crashes the 
test suites.


https://github.com/gedaiu/fluent-asserts/blob/master/core/fluentasserts/core/results.d#L1072

This exception can be captured only with a debugger... is it a 
dmd bug?


```
Thread 25CC created, Entry: mswsock.7FF9011604C0
EXCEPTION_DEBUG_INFO:
   dwFirstChance: 1
   ExceptionCode: C005 (EXCEPTION_ACCESS_VIOLATION)
  ExceptionFlags: 
ExceptionAddress: 7FF9055E302C ntdll.7FF9055E302C
NumberParameters: 2
ExceptionInformation[00]:  Read
ExceptionInformation[01]:  Inaccessible Address
First chance exception on 7FF9055E302C (C005, 
EXCEPTION_ACCESS_VIOLATION)!

```

I think this is related with this issue:
https://github.com/gedaiu/fluent-asserts/issues/63

Can anyone help me with this? I don't even know how to start 
fixing this issue...


Thanks,
Bogdan



Getting the coverage data at runtime

2017-06-18 Thread Szabo Bogdan via Digitalmars-d-learn

Hi,

I am wondering if there is any way of getting the code coverage 
at runtime... As a I seen in the runtime, the .lst files are 
created inside this module dealocator:


https://github.com/dlang/druntime/blob/master/src/rt/cover.d#L152

and the `Cover[] gdata;` is private, so no way of accessing it...

I'm asking this because it would be cool to analyse the coverage 
at runtime, after each executed test, for example, to see how 
many lines are covered by a test or to check if the test hits an 
assert, which will be awesome... Or maybe to add other coverage 
formats for better integration with IDEs...


Thanks!


Re: std.algorithm can not be used inside pure functions?

2017-05-06 Thread Szabo Bogdan via Digitalmars-d-learn

On Saturday, 6 May 2017 at 15:01:16 UTC, Adam D. Ruppe wrote:

On Saturday, 6 May 2017 at 14:14:41 UTC, Szabo Bogdan wrote:
oh yes, I get it... begin and end are `SysTime`.. there is any 
workaround for this?


Don't use pure?

I don't think any of the SysTime conversion methods are pure 
since all of them call C functions which pull from the time 
zone... even if you subclassed the timezone to be pure, SysTime 
wouldn't pick that up since it uses the impure interface.


I guess you could use a casted wrapper to hack in pure too, but 
I'd say just take the keyword off.


Thanks!


Re: std.algorithm can not be used inside pure functions?

2017-05-06 Thread Szabo Bogdan via Digitalmars-d-learn

On Saturday, 6 May 2017 at 13:21:10 UTC, Adam D. Ruppe wrote:

On Saturday, 6 May 2017 at 13:19:17 UTC, Szabo Bogdan wrote:

a.begin.toISOExtString,


I believe that function is not marked pure if it is a SysTime 
because it needs to pull global timezone info.


What is the type of a.begin?


oh yes, I get it... begin and end are `SysTime`.. there is any 
workaround for this?


std.algorithm can not be used inside pure functions?

2017-05-06 Thread Szabo Bogdan via Digitalmars-d-learn

Hi,

I'm trying to write a function that saves some structs as csv 
file:


```
string toCsv(const(StatStorage) storage) {
  return storage.values
.map!(a => [ a.name, a.begin.toISOExtString, 
a.end.toISOExtString, a.status.to!string ])

.map!(a => a.join(','))
.join('\n');
}
```

I think that it's obvious that this function has no external 
state and from my understanding, it should be a pure function. 
But when I declare it as `pure` I get an error `Error: pure 
function 'trial.reporters.stats.toCsv' cannot call impure 
function 'std.array.join!(MapResult!(__lambda3, 
MapResult!(__lambda2, const(Stat)[])), char).join'`.


What am I missing here?


Re: Stack Trace format

2017-04-30 Thread Szabo Bogdan via Digitalmars-d-learn

On Sunday, 30 April 2017 at 20:31:09 UTC, Szabo Bogdan wrote:

Hi,

I noticed that on different platforms the 
`object.Throwable.TraceInfo` has different formats. A program 
compiled on osx with ldc2 has all the TraceInfo empty... Why?


I want to parse those strings or somehow iterate trough all the 
stack elements, but if I get a different format on different 
platforms it's not that easy to determine at what position in 
the string is the address or the function name.


I would appreciate if anyone have an idea of how I can do this 
without a big headache...


Thanks!


Actually I found the `defaultTraceHandler` here:

https://github.com/dlang/druntime/blob/7caaf7cbb699a2a1944b2ac087c3b07d23db6802/src/core/runtime.d#L534


Stack Trace format

2017-04-30 Thread Szabo Bogdan via Digitalmars-d-learn

Hi,

I noticed that on different platforms the 
`object.Throwable.TraceInfo` has different formats. A program 
compiled on osx with ldc2 has all the TraceInfo empty... Why?


I want to parse those strings or somehow iterate trough all the 
stack elements, but if I get a different format on different 
platforms it's not that easy to determine at what position in the 
string is the address or the function name.


I would appreciate if anyone have an idea of how I can do this 
without a big headache...


Thanks!


code review based on what I learned from D

2015-07-05 Thread Szabo Bogdan via Digitalmars-d-learn

Hi,

Recently while I was reviewing some swift code, a colleague left 
me the impression that I am the one with the bad habits and these 
were learned while coding in D. I still think that I proposed 
some changes to avoid some bugs but I was told that I am focusing 
on defensive programming and that is a bad thing.


The first issue that I raised was this one:

func renderCell(item: AnyObject, index: Int) {
-fatalError(renderCell has not been implemented)
+
}

where I proposed to make that method abstract or let's not remove 
the fatalError message because this method it should be never 
called.


The second issue was this:

+init(dataSource: WUPTableDataSource) {
+
+self.dataSource = dataSource
+dataSource.tableView = tableView

where I asked what happens if someone passes a dataSource that 
has a tableView set. I this class, there were set some events 
bind to the view and it was unclear what happened in that case 
and I proposed to add an assert to check if dataSource.tableView 
is not set before we set it.


For both of these issues I was told that swift is not Java and if 
the situations that I described happens, you don't want to crash 
the user app, because this will make the user unhappy.


Those things are for me, good habits that I do when I am 
programming with D. What do you think? and if I had bad ideas 
with those issues, what I can do to improve my skills?


thanks,
Bogdan







sign oauth request

2014-09-25 Thread szabo bogdan via Digitalmars-d-learn

Hi,

How I can sign a request for flickrl oauth api?
https://www.flickr.com/services/api/auth.oauth.html#request_token

there is no HMAC-SHA1 algorithm in phobos library... should I 
implement it from scratch?


Thanks,
Bogdan


Re: sign oauth request

2014-09-25 Thread szabo bogdan via Digitalmars-d-learn

which lib do you recommand?


On Thursday, 25 September 2014 at 16:19:41 UTC, H. S. Teoh via 
Digitalmars-d-learn wrote:
On Thu, Sep 25, 2014 at 03:57:36PM +, szabo bogdan via 
Digitalmars-d-learn wrote:

Hi,

How I can sign a request for flickrl oauth api?
https://www.flickr.com/services/api/auth.oauth.html#request_token

there is no HMAC-SHA1 algorithm in phobos library... should I 
implement it

from scratch?

[...]

Implementing cryptographic algorithms on your own is probably 
not a good

idea. Your safest bet is to use one of the many C authentication
libraries out there, since D can call C functions directly.


T




Re: sign oauth request

2014-09-25 Thread szabo bogdan via Digitalmars-d-learn
On Thursday, 25 September 2014 at 17:09:40 UTC, Adam D. Ruppe 
wrote:
On Thursday, 25 September 2014 at 17:03:43 UTC, John Chapman 
wrote:

http://dlang.org/phobos/std_digest_sha.html#SHA1


Not quite the same, the oauth requires hmac.

When I did this in my oauth.d for twitter and stuff, I used the 
C library mhash


check out my code:

https://github.com/adamdruppe/arsd/blob/master/oauth.d#L796

The rest of that lib is kinda sloppy and has a few dependencies 
from my other modules but feel free to use whatever looks 
useful to you.


I think mhash is GPL licensed.



it works! thanks!